I have a custom SessionsController using Devise, when i browse /users/sign_in and enter some authdata then submit, have some errors.
NoMethodError in Users::SessionsController#create undefined method `serialize_into_session' for Symbol:Class Rails.root: /home/kewang/rails/devisetest Application Trace | Framework Trace | Full Trace devise (1.4.5) lib/devise/rails/warden_compat.rb:19:in `serialize' warden (1.0.5) lib/warden/session_serializer.rb:25:in `store' warden (1.0.5) lib/warden/proxy.rb:161:in `set_user' devise (1.4.5) lib/devise/controllers/helpers.rb:111:in `sign_in' app/controllers/users/sessions_controller.rb:3:in `create'
app/controllers/users/sessions_controller.rb
class Users::SessionsController < Devise::SessionsController
def create
sign_in(resource_name, resource)
end
end
app/helpers/application_helper.rb
module ApplicationHelper
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
end
config/routes.rb
devise_for :users, :controllers => { :sessions => "users/sessions" }
what can i do?
My development enviroment is Rails 3.1.0, Ruby 1.9.2
Devise has a bunch of custom methods that it uses in its controllers.
You could try calling super to get the methods, or
class Users::SessionsController < Devise::SessionsController
def create
sign_in(resource_name, resource)
super
end
end
But I would recommend including the whole Devise Sessions#create method, then changing things from that base. Link here
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
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