我有以下行的方法:为什么我无法在Rails 3中使用此参数创建?
26 User.create!(:email => "[email protected]", :linkedin_uid => linkedin_uid, :password => Devise.friendly_token[0,20])
这里是我的控制器:
20 def create
21 @user = User.new(params[:user])
22 if @user.save
23 flash[:notice] = "Successfully created user."
24 redirect_to @user
25 else
26 render :action => 'new'
27 end
28 end
从铁轨控制台
即使当我尝试通过将PARAMS来创建它:linkedin_uid,它仍然出来零。 :(
这里是该行的背景:
18 def self.find_for_linked_in_oauth(omniauth_hash, signed_in_resource=nil)
19 debugger
20 #omniauth_hash is a hash passed in from env["omniauth_hash"] by callback controller
21 linkedin_uid = omniauth_hash['uid']
22 debugger
23 if user = User.find_by_linkedin_uid(linkedin_uid)
24 user
25 else # Create an user with a stub password.
26 User.create!(:email => "[email protected]", :linkedin_uid => linkedin_uid, :password => Devise.friendly_token[0,20])
27 end
28 end
嗯,为什么:电子邮件和:密码通过了,但没有linkedin_uid? – Angela 2011-03-28 02:37:49
我以为你的意思是说对象没有被创建。现在看起来很清楚这是一个attr_accessible问题。我修改了我的答案。 – 2011-03-28 06:56:45