devise problem : xpected /home/roelof/tamara_devise/app/controllers/sessions_controller.rb to define

Hello,

Because I want to change something on login I copied the standard sessions controller to /app/controllers. Code :

class Devise::SessionsController < DeviseController prepend_before_filter :require_no_authentication, :only => [ :new, :create ] prepend_before_filter :allow_params_authentication!, :only => :create prepend_before_filter { request.env[“devise.skip_timeout”] = true }

GET /resource/sign_in

def new self.resource = build_resource(nil, :unsafe => true) clean_up_passwords(resource) respond_with(resource, serialize_options(resource)) end

POST /resource/sign_in

def create self.resource = warden.authenticate!(auth_options) set_flash_message(:notice, :signed_in) if is_navigational_format? sign_in(resource_name, resource) respond_with resource, :location => after_sign_in_path_for(resource) end

DELETE /resource/sign_out

def destroy redirect_path = after_sign_out_path_for(resource_name) signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)) set_flash_message :notice, :signed_out if signed_out && is_navigational_format?

# We actually need to hardcode this as Rails default responder doesn't
# support returning empty response on GET request
respond_to do |format|
  format.any(*navigational_formats) { redirect_to redirect_path }
  format.all do
    head :no_content
  end
end

end

protected

def serialize_options(resource) methods = resource_class.authentication_keys.dup methods = methods.keys if methods.is_a?(Hash) methods << :password if resource.respond_to?(:password) { :methods => methods, :only => [:password] } end

def auth_options { :scope => resource_name, :recall => “#{controller_path}#new” } end end

Also I changed this in routes.rb :

devise_for :users, :controllers => { :sessions => “sessions” }

but when I want to log in I see this error message :

expected /home/roelof/tamara_devise/app/controllers/sessions_controller.rb to define SessionsController

with this trace :

activesupport (3.2.8) lib/active_support/dependencies.rb:503:in `load_missing_constant'
activesupport (3.2.8) lib/active_support/dependencies.rb:192:in `block in const_missing'
activesupport (3.2.8) lib/active_support/dependencies.rb:190:in `each'
activesupport (3.2.8) lib/active_support/dependencies.rb:190:in `const_missing'
activesupport (3.2.8) lib/active_support/inflector/methods.rb:230:in `block in constantize'
activesupport (3.2.8) lib/active_support/inflector/methods.rb:229:in `each'
activesupport (3.2.8) lib/active_support/inflector/methods.rb:229:in `constantize'
activesupport (3.2.8) lib/active_support/dependencies.rb:554:in `get'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:54:in `controller'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:32:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/mapper.rb:42:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.8) lib/action_dispatch/routing/route_set.rb:600:in `call'
warden (1.2.1) lib/warden/manager.rb:35:in `block in call'
warden (1.2.1) lib/warden/manager.rb:34:in `catch'
warden (1.2.1) lib/warden/manager.rb:34:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.1) lib/rack/etag.rb:23:in `call'
rack (1.4.1) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in `context'
rack (1.4.1) lib/rack/session/abstract/id.rb:200:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/cookies.rb:339:in `call'
activerecord (3.2.8) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `_run__74323296227737834__call__1400684879403415965__callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.8) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.8) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.8) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.8) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.8) lib/rails/engine.rb:479:in `call'
railties (3.2.8) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/usr/share/ruby/webrick/httpserver.rb:138:in `service'
/usr/share/ruby/webrick/httpserver.rb:94:in `run'
/usr/share/ruby/webrick/server.rb:191:in `block in start_thread'

Anyone knows how to solve this ?

Roelof

Hello,

Because I want to change something on login I copied the standard sessions controller to /app/controllers. Code :

class Devise::SessionsController < DeviseController

...

end

...

but when I want to log in I see this error message :

expected /home/roelof/tamara_devise/app/controllers/sessions_controller.rb to define SessionsController

Maybe it's gritching about the difference between Devise::SessionsController (which you've got there) and just plain SessionsController (which it says it's expecting that file to define). Try removing the Devise:: part.

-Dave