语法错误,意外的 '\n',期待 =>

Han*_*CRW 0 ruby ruby-on-rails devise omniauth ruby-on-rails-4

我正在登录页面上为 LinkedIn 实施 OmniAuth,但出现此错误:

SyntaxError  
/app/models/user.rb:9: syntax error, unexpected '\n', expecting =>  
Run Code Online (Sandbox Code Playgroud)

它正在查看的代码是这样的:

class User < ActiveRecord::Base  
  attr_accessor :email, :password, :password_confirmation  
  VALID_EMAIL_REGEX = /([\w+.]+)@[a-z0-9\-.]+\.[a-z]+/i   
  validates :email, presence: true,   
                    format: { with: VALID_EMAIL_REGEX },   
                    uniqueness: { case_sensitive: false }  
  validates :password, presence: true, length: { minimum: 6 }  
  validates :password_confirmation, presence: true  
  devise :rememberable, :omniauthable, :omniauth_providers => [:linkedin], :trackable
end
Run Code Online (Sandbox Code Playgroud)

请问有什么建议吗?

小智 5

尝试重新排序

devise :rememberable, :omniauthable, :trackable, :omniauth_providers => [:linkedin]
Run Code Online (Sandbox Code Playgroud)

  • **补充**:散列周围的大括号只能在散列是最后一个参数时省略。 (3认同)