I am following OmniAuth railscasts and trying to implement the same with authlogic + facebook instead of devise + twitter, as shown in railscast.
Maybe my understanding of has_many is still not very good, but in railscasts ryan has the following code in AuthenticationsController
def create auth = request.env["rack.auth"] current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid']) flash[:notice] = "Authentication successful." redirect_to authentications_url end
In my implementation, current_user.authentications returns an array [] , how can I call find_or_create_by_provider_and_uid in the array?
Is my implementation wrong? Does has_many not return an array?
The error I get is that I call find_or_create_by_provider_and_uid on the nil object.
current_user.authentications is zero because the user does not have any authentications yet.
source share