开发者

How to change Devise's root controller path in a Rails 3?

I have a Rails 3 app that uses Devise. How do I go about changing devise's root controller to something other than the application's root controller.

In my routes.rb file, I have the appl开发者_开发技巧ications root set as root :to => 'home#index' so http://app.com/users/sign_in will call up the devise form which is not what I want.

I also have the following in routes.rb (this is the route that I want devise to use):

  scope :module => 'control' do
    constraints :subdomain => 'control' do
      resources :offers
      root :to => 'offers#index'
    end
  end

How can I point devise to use the above path (control.app.com) so that the user sign in would be located at http://control.app.com/users/sign_in?

Thanks!

Tim


Maybe you need to use devise_scope when defining your root route for your sign-in page and pass your subdomain in there? Just a guess.

"Configuring routes" in https://github.com/plataformatec/devise/blob/master/README.rdoc may be of some help.


I've found the solution. I added devise_for inside the scope as so:

  scope :module => 'control' do
    constraints :subdomain => 'control' do
      devise_for :users, :module => 'devise'
      resources :offers
      root :to => 'offers#index'
    end
  end

You need to add :module => 'devise' because the module is changed to the namespace's name, so you have to set it back to 'devise'. Now I can access all the devise actions with the control subdomain (ex. control.app.com/users/sign_in, control.app.com/users/sign_up, etc)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜