I am following OmniAuth railscasts and trying to implement the same with authlogic + facebook instead of devise + twitter as shown in the railscast.
Maybe my understanding of has_many
still isn't good but in the 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
on an array?
Is my implementation wrong? Isn't has_many
suppose to return an array?
Error I get is that I am calling find_or_create_by_provider_and_uid
on a nil
object.
current_user.authentications
is nil well because the user does not have any authentications yet.
has_many
bring back an array? – Furring