Layout for Devise with scoped route
Hey Everyone,
I'm trying to use a custom layout for my devise/registrations#edit
view. I'm using a scoped route.
devise_scope :member do
get "/members/:id/settings" => "devise/registrations#edit", as: "edit_member_registration"
end
I call the layout in my registrations controller layout "member_area", only: :edit
, but it's not showing.
I have a feeling it has to do with the scoped route. Also, if I take off the only: :edit
the layout shows up on the other registration pages as expected.
Anyone have any thoughts on this?
Thanks for any help!
Nick
Hey Nick,
I'm still a bit foggy on devise and the routes, so this may not be the best way, but I had to do a similar setup where each user type had their own layout for the various devise functions and this is what has been working for that project:
devise_for :members, controllers: { registrations: 'members/registrations'}, :path => '', :path_names => {:sign_in => 'member_login', :sign_up => 'member_signup'}
Then for the views, you'll have a structure similar to this:
- views
- members
- registrations
- edit
- new
And your controllers like:
- controllers
- members
- registrations_controller.rb
Would love for someone with more expertise to chime in if there's a better way!
Hey Jacob,
Thanks for the help! Unfortunately I still can't get the layout to display. I think I'm just going to move onto plan b for now.
I really appreciate your help!
Nick
Doh, well sometimes that's how it goes until we have more time!
Something I forgot to mention in my original post was that the registrations_controller.rb
doesn't need any layout
specified, you just need to make sure to namespace the controller...
class Members::RegistrationsController < Devise::RegistrationsController