type mismatch:给定字符串 - 尝试匹配ruby中的字符串

Arc*_*Arc 5 ruby regex haml authlogic ruby-on-rails-3

我在Rails中使用authlogic-connect.我正在使用一个简单的haml模板,我不想显示已添加的授权提供程序.

%h2 My Account
%form.authentication_form{:action => connect_path, :method => :post}
  %fieldset
    %input{:type => :hidden, :name => :authentication_type, :value => :user}
    %legend Add another Oauth or OpenID provider.
    .oauth_providers
      %ul
        - %w(google facebook twitter yahoo).each do |name|
          %li.oauth_provider
            -unless "{user.authenticated_with}" =~ "{name}"
              %img{:src => "/images/icons/#{name}.png"}
              %input{:type => :radio, :id => "#{name}_oauth_provider", :name => :oauth_provider, :value => name}
        .clearfix
  %input.submit{:name => :submit, :type => :submit, :value => "Update"}/
Run Code Online (Sandbox Code Playgroud)

我遇到错误类型不匹配:字符串.user.authenticated返回一个字符串.

def authenticated_with
      @authenticated_with ||= self.access_tokens.collect{|t| t.service_name.to_s}
    end
Run Code Online (Sandbox Code Playgroud)

有什么问题可能?

堆栈跟踪:

ActionView::Template::Error (type mismatch: String given):
    7:       %ul
    8:         - %w(google facebook twitter yahoo).each do |name|
    9:           %li.oauth_provider
    10:             -unless "{user.authenticated_with}" =~ "{name}"
    11:               %img{:src => "/images/icons/#{name}.png"}
    12:               %input{:type => :radio, :id => "#{name}_oauth_provider", :name => :oauth_provider, :value => name}
    13:         .clearfix
  app/views/users/edit.html.haml:10:in `=~'
  app/views/users/edit.html.haml:10:in `_app_views_users_edit_html_haml___2062853011_2171399360_0'
  app/views/users/edit.html.haml:8:in `each'
  app/views/users/edit.html.haml:8:in `_app_views_users_edit_html_haml___2062853011_2171399360_0'
Run Code Online (Sandbox Code Playgroud)

提取的来源(第10行): - 在第10行显示错误

tok*_*and 14

将正则表达式作为参数传递给String#=〜:

>> string = "el"
>> "hello" =~ /#{string}/
=> 1
Run Code Online (Sandbox Code Playgroud)