0
votes

I feel like my brain left the building when I was learning Rails routing... I can't figure this out.

So I have customized some devise controller, and therefore I have updated the route file like so:

 devise_for :users, controllers: { 
    registrations: "users/registrations", 
    sessions: "users/sessions", 
    passwords: "users/passwords"
 }

That works GREAT. It gives me paths like this:

new_user_registration GET    /users/sign_up(.:format)         users/registrations#new

The challenge now is I want to run an A/B test using Google Analytics where I need 2 more pages for the sign up.

So in my controller this is how I would modify:

class Users::RegistrationsController < Devise::RegistrationsController

  def new
  end

  # ADD BELOW
  def new_control
  end

  def new_test
  end
end

But I can't figure out how to modify my routing so that I have these 2 new routes in additional to the old new_user_registration_path (note the named path helper for these new ones don't matter so much to me because I never actually use it)

GET    /users/sign_up/control(.:format)         users/registrations#new_control
GET    /users/sign_up/test(.:format)         users/registrations#new_test

Note that I want to keep all the other lovely routes the devise_for code has created, e.g., the create and edit actions

1

1 Answers

0
votes

You can access specify the route normally as you would do in a rails app. Only thing you need to do is wrap the route inside a device_scope. This also shows up as warning when you try to access the route without adding the device_scope.

So in your case routes should be like:

devise_scope :user do
  get 'users/sign_up/control' => 'users/registrations#new_control'
  get 'users/sign_up/test' => 'users/registrations#new_test'
end