小编Gug*_*ght的帖子

Rails 4:循环遍历数组

我想我做的事情非常糟糕.我收到此错误:

TypeError
no implicit conversion of nil into String
Run Code Online (Sandbox Code Playgroud)

如果我把它放在我的视图(haml)中:

...

- ["Greg", "is", "cool", "ya"].each do |tag|
    .tagwrapper
        = link_to tag.to_s.gsub!(/[^0-9A-Za-z]/, ''), '/search?searchtags='+tag.to_s.gsub!(/[^0-9A-Za-z]/, ''), class: 'smaller half-stretched'

...
Run Code Online (Sandbox Code Playgroud)

我应该怎么做呢?

ruby arrays loops ruby-on-rails ruby-on-rails-4

0
推荐指数
1
解决办法
63
查看次数

标签 统计

arrays ×1

loops ×1

ruby ×1

ruby-on-rails ×1

ruby-on-rails-4 ×1