在注册页面,提交后报 TypeError in Devise::RegistrationsController#create nil is not a symbol
啥问题呢?
还有登陆时候,提交后没报异常,直接返回登陆页面,但是我看表里也没有记录登陆信息,用 user_signed_in? 返回 false。
# You can have the root of your site routed with "root" # just remember to delete public/index.html. root :to => 'index#index'
设置了啊
路由代码: devise_for :users,:path => "account"
控制台信息:
Started POST "/account/sign_in" for 127.0.0.1 at 2012-01-06 14:32:24 +0800
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"鉁?, "authenticity_token"=>"0TMBy1+VHXuvP2xzy03cRrNZuR7hKKqm3a/uE+xZURo=", "user"=>{"email"=>"[email protected]", "password"=>"[FIL
TERED]"}, "barcode"=>"1234"}
[1m[36mUser Load (1.0ms)[0m [1mSELECT users
.* FROM users
WHERE users
.email
= '[email protected]' LIMIT 1[0m
Completed 401 Unauthorized in 468ms
Processing by Devise::SessionsController#new as HTML
Parameters: {"utf8"=>"鉁?, "authenticity_token"=>"0TMBy1+VHXuvP2xzy03cRrNZuR7hKKqm3a/uE+xZURo=", "user"=>{"email"=>"[email protected]", "password"=>"[FIL
TERED]"}, "barcode"=>"1234"}
Rendered index/_top.html.erb (0.0ms)
Rendered devise/sessions/new.html.erb within layouts/application (6.0ms)
Completed 200 OK in 118ms (Views: 19.0ms | ActiveRecord: 0.0ms)
没有发现异常啊...
没报错,我知道的已经贴出来了。
登陆后什么都没提示又返回登陆页面,就这样。 注册页面就报: TypeError in Devise::RegistrationsController#create nil is not a symbol
user model:
#encoding: utf-8 class User < ActiveRecord::Base set_table_name "users" # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable,:registerable,:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me end
基本上都是 devise 自动生成的
看了下源码 def create
resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
logger.debug "========================="
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
貌似在 resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new") 就出问题了, 后面的 debug 都不能正确输出..
重新建立一个项目试了下 始终报“Invalid email or password." email 和密码填写正确也报这个..数据库我看也查询了,不过只查询的 email,条件中没加入密码..不知道哪里还配置错误
哈哈哈,已经解决。 1) TypeError in Devise::RegistrationsController#create nil is not a symbol
该错误在登陆或注册时候遇到,我把 users 表删除重新建解决,奇怪。
2) 之前说登陆后一直跳回原来页面 自己的问题,该表中有 password 字段,用来存放明文,后来试验 devise 把密码存在 encrypted_password 字段中,然后我在页面也没放
<%= notice %>
<%= alert %>
所以永远也不知道怎么回事..现在终于解决,谢谢各位