DangerousAttributeError w OmniAuth Railscast Tutorial: tworzenie jest zdefiniowane przez ActiveRecord
ObejrzałemActiveRecord :: DangerousAttributeError i inne podobne wątki na SO, ale nie dotyczą tego samego problemu.
Śledzę samouczek omniauth:http://railscasts.com/episodes/235-omniauth-part-1?view=asciicast
Jestem w stanie uwierzytelnić się poprzez oauth na Twitterze i zwrócić dane użytkownika (auth). Problem polega na tym, że nie mogę utworzyć / zapisać go w bazie danych (sqlite3) z powodu tego komunikatu o błędzie.
Błąd:<code>ActiveRecord::DangerousAttributeError in AuthenticationsController#create create is defined by ActiveRecord Rails.root: /beta/devise-omniauth1 Application Trace | Framework Trace | Full Trace app/controllers/authentications_controller.rb:15:in `create' </code>Sterownik Authentication_Controller:
<code> def create auth = request.env["omniauth.auth"] current_user.authentications.create(:provider => auth['provider'], :uid => auth['uid']) flash[:notice] = "Authentication successful." redirect_to authentications_url end </code>Modele:
<code>class Authentication < ActiveRecord::Base belongs_to :user end class User < ActiveRecord::Base has_many :authentications # 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 </code>
Jak pracować po tym błędzie? Googling na tej stronie i innych nie pomaga mi zrozumieć, co się dzieje, aby to naprawić. Dzięki