Question

Using Rails 4 and Devise 3, I would like to have different registration pages based on the URL my user is given.

As an example, each of the following should be directed to a different view that acts as devise registration.

www.mydomain.com <-- current root to registrations#new
www.mydomain.com/user_type_1
www.mydomain.com/user_type_2
www.mydomain.com/user_type_3

How would I do this? I can copy app/views/devise/registrations/new.html.erb to capture the form but how would I make the routing work?

My routes are currently set up as such (I close each session so the user can sign up a friend, but that is not relevant to this question)

devise_scope :user do
  authenticated :user do
    root :to => 'devise/sessions#destroy', as: :authenticated_root
  end
  unauthenticated :user do
    root :to => 'devise/registrations#new', as: :unauthenticated_root
  end
end
Was it helpful?

Solution

So you want three different url paths that point to three different views, but you want the forms to all send their info to the same REST endpoint in the same controller (users#create)? That sounds simple. You have GET requests to get the html/erb files for each registration page (welcome#index, welcome#cool, welcome#coolest), and routes for each to send the GET request to the right controller action.

Then you set up the forms to all send their info to POST to users#new, and one route from there.

Does that make sense?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top