更新if语句中的Object时出现Rails语法错误

时间:2014-11-06 21:14:40

标签: ruby-on-rails

我无法弄清楚为什么会抛出语法错误:

  if feeds.include? 'job'
      #when only updating one attribute use this over 'update(params)'
      broadcast.update_attribute(:jobs true)
    else
      #do nothing at the moment
  end

错误信息是:

app/models/broadcast_service.rb:17: syntax error, unexpected keyword_true, expecting ')'
app/models/broadcast_service.rb:100: syntax error, unexpected $end, expecting keyword_end

:jobsboolean,我想将其值设置为true

其中line 17 is the aboveline 100 is the very last line of the fileend keyword

1 个答案:

答案 0 :(得分:0)

愚蠢的我错过了参数之间的逗号。

if feeds.include? 'job'
      #when only updating one attribute use this over 'update(params)'
      broadcast.update_attribute(:jobs, true)
    else
      #do nothing at the moment
  end