我正在尝试使用Rails 4&设计。
我正在尝试遵循本教程:
http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin/
当我完成这些步骤并运行服务器时,我收到此错误
class Comparer : IEqualityComparer<KeyValuePair<KeyValuePair<string,string>, int>>
{
// Products are equal if their names and product numbers are equal.
public bool Equals(KeyValuePair<KeyValuePair<string,string>, int> x, KeyValuePair<KeyValuePair<string,string>, int> y)
{
//Check whether the compared objects reference the same data.
if (Object.ReferenceEquals(x, y)) return true;
//Check whether any of the compared objects is null.
if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null))
return false;
//Check whether the products' properties are equal.
return x.Key.Key == y.Key.Key || x.Key.Value == y.Key.Value;
}
public int GetHashCode(KeyValuePair<string,string> kvp)
{
//Check whether the object is null
if (Object.ReferenceEquals(kvp, null)) return 0;
return kvp.GetHashCode();
}
}
//call Intersect using the custom comparer
dict1.Intersect(dict2, new Comparer());
完成注册方法是:
NoMethodError (undefined method `update' for nil:NilClass):
2015-12-14T20:37:03.180526+00:00 app[web.1]: app/controllers/users_controller.rb:43:in `finish_signup'
2015-12-14T20:37:03.180540+00:00 app[web.1]:
确定为问题的具体行是:
def finish_signup
# authorize! :update, @user
if request.patch? && params[:user] #&& params[:user][:email]
if @user.update(user_params)
@user.skip_reconfirmation!
sign_in(@user, :bypass => true)
redirect_to @user, notice: 'Your profile was successfully updated.'
else
@show_errors = true
end
end
end
有谁看到出了什么问题?我不知道如何阅读错误以了解其抱怨的内容。有谁能看到这个问题?
答案 0 :(得分:0)
您收到错误,因为@user
为nil
。
我可以从您的评论中看到,您需要更新此
before_action :set_user, only: [:index, :show, :edit, :update, :destroy]
到这个
before_action :set_user, only: [:index, :show, :edit, :update, :destroy, :finish_signup]