我有以下行的方法:爲什麼我無法在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