ActionView :: Template ::错误:未定义的方法`split'为零:NilClass

时间:2016-02-22 12:33:26

标签: ruby-on-rails ruby

我遇到了上述错误。我无法找到解决方案。请告诉我。

这是我的feed_view_mobile.erb代码;

if params[:controller]=='categories'
    meta :title => " #{feed_hash[:filter_keyword]+' | ' if feed_hash[:filter_keyword].present?} " + (feed_hash[:seo_title]||feed_hash[:title]) + ( ((' - Page ' + params[:page]) if params[:page].present?) ||''),
    :description => " #{feed_hash[:filter_keyword]+' | ' if feed_hash[:filter_keyword].present?} " + (feed_hash[:description] || '') + ( ((' - Page ' + params[:page]) if params[:page].present?) ||''),
    :keywords => (feed_hash[:filter_keyword].split.select{ |x| x.length>2}).concat(feed_hash[:keywords] || feed_hash[:title].split.select{ |x| x.length >2 })
    #salwar special case for testing.
    @secondary_message = "<a class='btn btn-primary btn-attn' href='"+new_user_registration_path.to_s+"'>Signup </a>" + "  and get your free personal stylist." if !current_user.present? && params[:term]!="salwars-churidars"
    @secondary_message = ""
end

1 个答案:

答案 0 :(得分:1)

Feed [:filter_keyword]或filter [:title]似乎都是零。

使用方法try检查你如何设置这些值或处理它们可能为零的情况。