【问题标题】:Why does undefined method `-@' for nil:NilClass mean (haml)?为什么 nil:NilClass 的未定义方法 `-@' 表示 (haml)?
【发布时间】:2014-08-25 00:39:46
【问题描述】:

我有这个 Rails 视图部分,但我看不到问题:

%span{class: "show_hide #{show_hide}"}
  ---------------------
  = first_field_focus
  ---------------------
  - if first_field_focus == "1" 
    - puts '++++++++++++'
    - puts 'y' 
    - puts '.............'
    - puts '.............'
    - puts '==='
  %a{href: '#', :data => {toggle_description_length: 'toggle'}} # Line 11
    = raw(txt)

但我只是不断得到:

NoMethodError in Links#index

Showing /home/durrantm/Dropnot/webs/rails_apps/linker/app/views/links/_toggle_details_link_bold.html.haml where line #11 raised:

undefined method `-@' for nil:NilClass

Extracted source (around line #11):
...

【问题讨论】:

    标签: ruby-on-rails haml


    【解决方案1】:

    这意味着您正在尝试调用 - 运算符来处理 nil。可能那些--------------------- 行被解释为一个代码行,它是一个负号链,它使事情变得混乱。尝试改为\---------------------

    【讨论】:

      猜你喜欢
      • 2014-01-13
      • 1970-01-01
      • 2011-08-22
      • 1970-01-01
      • 2011-07-27
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多