I'm following the railscast for omniauth pretty closely but I'm getting this error that is not experienced in the video
Can't mass-assign protected attributes: provider, uid
Here's the authentication controller that I created
class AuthenticationsController < InheritedResources::Base
def index
@authentications = current_user.authentications if current_user
end
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.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
flash[:notice] = "Authentication successful"
redirect_to authentications_url
else
user = User.new
user.apply_omniauth(omniauth)
user.save(:validate=>false)
flash[:notice] = "Signed in successfully"
sign_in_and_redirect(:user, user)
end
end
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:notice] = "Successfully destroyed authentication"
redirect_to authentications_url
end
end
Here's what I have for user.rb where I have added :provider and :uid to attr_accessible after looking at past threads
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation, :provider, :uid
has_many :authentications
Unfortunately, I'm still getting this error when I try to login using Twitter (path = /auth/twitter/callback)
provideranduidinAuthenticationmodel because u call methodcreate!on this model - Eruprivate methodapply_twitter' called` error on that same controller.. do you know why? - johbones