Reputation: 1093
I'm having difficulties adjusting the controller in the gem devise. On https://github.com/plataformatec/devise there is a guide to configure controllers:
Create your custom controllers using the generator which requires a scope:
rails generate devise:controllers [scope]
I typed in: rails generate devise:controllers users
Tell the router to use this controller:
devise_for :users, controllers: { sessions: "users/sessions" }
I added devise_for :users, controllers: { sessions: "users/sessions" }
to the routes
I created a folder in users called sessions and I copied the views from devise/sessions to users/sessions
4.Finally, change or extend the desired controller actions.
At this point, I should be able to adjust the controller, but nothings happens. For example, when I do this:
registrations/new.html.erb
<h2>Sign up</h2>
<% @user.each do |name|%>
<%= name.username %>
<% end %>
users/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
# before_filter :configure_sign_up_params, only: [:create]
# before_filter :configure_account_update_params, only: [:update]
# GET /resource/sign_up
def new
@user = User.all
super
end
# POST /resource
# def create
# super
# end
Nothing happens. Where did I go wrong? You can access the code here: https://github.com/Metaphysiker/philosophica
Thanks in advance!
Upvotes: 1
Views: 179
Reputation: 2296
First it looks like you typed:
rails generate devise:controllers [users]
users in []
so you got a folder called [users]
You may want to delete that.
But your actual problem is that you did not move the views to views/users/session
the folder views/users
has only a new.erb. Copy the content of views/devise
to views/users
and you get what you want.
Aditionaly you should add devise_for :users, controllers: { sessions: "users/sessions" , registrations: „users/registrations“ }
to your routes.rb
Upvotes: 1