[]:Array的未定义方法`find_by_provder_and_uid'

时间:2011-05-05 17:39:36

标签: ruby-on-rails ruby-on-rails-3

我正在按照这里的教程进行操作:

http://asciicasts.com/episodes/235-omniauth-part-1

在我的控制器中,我创建了以下方法:

  def create  
    auth = request.env["omniauth.auth"]
    current_user.authentications.find_or_create_by_provder_and_uid(auth['provider'], auth['uid'])
    flash[:notice] = "Authentication successful."
    redirect_to authentications_url  
  end

问题是错误如此:

undefined method `find_by_provder_and_uid' for []:Array

想法为什么?感谢

1 个答案:

答案 0 :(得分:5)

看起来这个页面有一个拼写错误 - 它应该是:

    current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])

原始Railcast拼写正确。我刚刚给AsciiCasts作者发了电子邮件,通知他这个错字。