I want to use my devise generated views (with command rails g devise:views users
) from app/views/users
.
I already have set these options from app/initializers/devise.rb
:
config.scoped_views = true
config.default_scope = :user
but it still uses default devise views from /usr/lib/ruby/gems/1.8/gems/devise-2.0.4/app/views/devise/
So what should I do? Thanks.
Devise is the cornerstone gem for Ruby on Rails authentication. With Devise, creating a User that can log in and out of your application is so simple because Devise takes care of all the controllers necessary for user creation ( users_controller ) and for user sessions ( users_sessions_controller ).
I was having this same problem and it took me forever to figure it out. Setting config.scoped_views = true
is the first step, but there's another step that's not as clear.
If you look closely at some of the views that get generated by rails g devise:views users
you'll see that the templates include <%= render "devise/shared/links" %>
at the bottom of the file. Since you have generated these views, the shared links are now located in users/shared/links
. Since devise doesn't find anything in devise/shared/links
anymore, it uses the default links view instead.
Change <%= render "devise/shared/links" %>
to <%= render "users/shared/links" %>
and you're set!
For a custom login view, when you're using the default User
devise resource, I think all you need is to create app/views/devise/sessions/new.html.erb
. And, just for the moment, let's forget about the CRUD interface. And undo those config/initializers/devise.rb
settings. Just see if you can get that working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With