0
def create
            omniauth = request.env["omniauth.auth"]
            authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
            if authentication
              flash[:notice] = "Signed in successfully"
              sign_in_and_redirect(:user, authentication.user)
            elsif current_user
              current_user.authentication.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
              flash[:notice] = "Authentication successful"
              redirect_to authentication_url
            else
              user = User.new
              user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
              user.save!
              flash[:notice] = "Authentication successful"
              sign_in_and_redirect(:user, user)
            end
 end

这是用于创建 twitter 身份验证的代码。然而,在第 13 行,

user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
      user.save!

引发错误。

destroy is defined by Active Record

我在网上没有找到任何帮助。我正在关注 railscast 236。Rails 版本 4.0.0,ruby 版本 2。任何帮助将不胜感激。

4

1 回答 1

3

检查您的表格并确保您没有列名,例如

index, create, destroy, delete
于 2013-08-02T02:51:02.517 回答