Devise registration controller conflict with my own “registrations” controller

女生的网名这么多〃 提交于 2019-12-21 23:33:49

问题


I'm in a bit of a pickle here as I have used Daniel Kehoe's excellent Rails Composer to build a small app. I'm also using Devise for authentication.

I had the bright idea to create a "registrations" controller/model to enable my users to register to different classes they want to attend. Obviously, this is wrecking havoc in my app and I'd like to know what is the best way to get out of this said pickle :)

I'm left with two choices and would like to have you Rails experts chime in:

  1. Rename my registrations controller and leave Devise alone (I'm guessing this is better in the long run if Devise is updated etc..)
  2. Change how the Devise routes are named in the config/routes.rb file.

What change should I plan on doing?

Thanks for your help!

Francis


回答1:


Wrap your registrations controller in a module/namespace.

Classroom::RegistrationsController
end

Then make sure the views of the registrations controller are inside a directory of classroom.

-views
--classroom
---registrations
----new.html.erb

In your routes.rb, put the regsitration routes in a namespace.

namespace :classroom do
 resources :registrations
end


来源:https://stackoverflow.com/questions/14944847/devise-registration-controller-conflict-with-my-own-registrations-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!