I want to change the path after new registration after logging in with multiple devises.

The original application is being created.

I have summarized what to do if you want to create multiple devises and set the path after routing after login.

First, assume that you have installed two or more devises, set devise_parameter_sanitizer, and so on.

If you haven't done so, please refer to here.

Routing settings from file creation when creating multiple devises and creating separate login screens

Individual settings of devise_parameter_sanitizer when creating two devises

<< What you want to do >>

I want to set the routed path of a nested devise.

http://localhost:3000/users/1/medicines

↑ I want to create a URL like this. I want to set the routine of the index of medicine whose id of users is 1.

① Routing settings

I want to nest it, so I want to nest the routing. Use member do here.

What is member do? The id is attached to the routing.

   resources :users do
      member do
        resources :medicines 
      end
   end

Nest like this.

(2) Set the controller for user's devise.

    protected

  def after_sign_in_path_for(*)
    medicines_path(current_user.id)
  end

I will explain.

Since the path will be changed after the login screen, describe it in /users/session_controller.rb. This time it is a path change in multiple devise, so write it in the users directory. If it is doctor devise, describe it in doctor / session_controller.rb.

after_sign_in_path_for is a method that specifies the path after signing in devise. (*) Is an argument that contains login information. The information received at the time of login is passed from the routing to the controller. Go to medicines_path with id as medicines_path (current_user.id) and determine which id current_user.id is from the received information.

I learned that it is important to set the path where it goes, whether it can pass arguments (information), or whether there is a place to disperse it.

Recommended Posts

I want to change the path after new registration after logging in with multiple devises.
After posting an article with Rails Simple Calendar, I want to reflect it in the calendar.
[Java] I want to perform distinct with the key in the object
I want to change the value of Attribute in Selenium of Ruby
I want to select multiple items with a custom layout in Dialog
I want to truncate after the decimal point
I want to get the value in Ruby
How to change the action with multiple submit buttons
I want to embed any TraceId in the log
I want to dark mode with the SWT app
I want to hit the API with Rails on multiple docker-composes set up locally
I want to find a relative path in a situation using Path
I want to set the conditions to be displayed in collection_check_boxes
[Rails] [bootstrap] I want to change the font size responsively
I want to change the log output settings of UtilLoggingJdbcLogger
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I want to distinct the duplicated data with has_many through
I want to transition to the same screen in the saved state
I want to return multiple return values for the input argument
I want to pass the startup command to postgres with docker-compose.
I want to simplify the conditional if-else statement in Java
In Java, I want to trim multiple specified characters from only the beginning and end.
I want to change the color of the upper control navigation bar (Control menu) in Liferay 7 / DXP
I want to recreate the contents of assets from scratch in the environment built with capistrano
I want to return to the previous screen with kotlin and java!
I want to display the images under assets/images in the production environment
I want to remove the top margin in Grouped UITableView (swift)
[Android] I want to get the listener from the button in ListView
I tried to solve the past 10 questions that should be solved after registering with AtCoder in Java
[For beginners] I want to automatically enter pre-registered data in the input form with a selection command.
I want to write JSP in Emacs more easily than the default.
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (PowerMockito edition)
[Note] I want to get in reverse order using afterLast with JdbcTemplate
I tried to solve the tribonacci sequence problem in Ruby, with recursion.
I want to display a PDF in Chinese (Korean) with thin reports
I want to get the IP address when connecting to Wi-Fi in Java
I want to display an error message when registering in the database
I was addicted to unit testing with the buffer operator in RxJava
I want to ForEach an array with a Lambda expression in Java
I want to introduce the committee with Rails without getting too dirty
After all I wanted to preview the contents of mysql with Docker ...
I want to use DBViewer with Eclipse 2018-12! !!
I tried the new era in Java
I want to use @Autowired in Servlet
[Rails] [Parent-child relationship] I want to register the foreign key in the child with nil when the parent is deleted.
I want to control the start / stop of servers and databases with Alexa
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (Javassist second decoction)
[For rails beginners] Specify transition destination after logging in to multiple Devise models
[Rails] How to register multiple records in the intermediate table with many-to-many association
Development memo ~ I want to display only the first image posted multiple times ~
[Eclipse] I want to use the completion function, but I want to manage to confirm the completion with spaces.
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (black magic edition)
I want to test Action Cable with RSpec test
I want to output the day of the week
I want to get the information of the class that inherits the UserDetails class of the user who is logged in with Spring Boot.
Assignment to multiple variables with the ternary operator
I want to send an email in Java.
I tried to organize the session in Rails
I want to use arrow notation in Ruby
I want to use java8 forEach with index
I want to var_dump the contents of the intent