【问题标题】:Rake db:migrate syntax error耙分贝:迁移语法错误
【发布时间】:2010-09-22 12:38:33
【问题描述】:

尝试设置 webistrano 并收到以下错误:

rake db:migrate

(in /var/www/html/webistrano)
rake aborted!
/var/www/html/webistrano/vendor/rails/activesupport/lib/active_support/inflector.rb:273: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
        when 1: "#{number}st"
               ^
/var/www/html/webistrano/vendor/rails/activesupport/lib/active_support/inflector.rb:274: syntax error, unexpected keyword_when, expecting keyword_end
        when 2: "#{number}nd"
            ^
/var/www/html/webistrano/vendor/rails/activesupport/lib/active_support/inflector.rb:275: syntax error, unexpected keyword_when, expecting keyword_end
        when 3: "#{number}rd"
            ^
/var/www/html/webistrano/vendor/rails/activesupport/lib/active_support/inflector.rb:280: syntax error, unexpected keyword_end, expecting $end

【问题讨论】:

    标签: ruby-on-rails rake webistrano


    【解决方案1】:

    检查类似 switch 语句的 ruby​​ 语法,when 后面没有“:”。

    case foo
      when "bar"
        # do stuff
      when "bar2"
        # do other stuff
    end
    

    顺便说一句,您为什么要这样做?如果我正确阅读了您的代码,也许您应该看看ordinalize 方法。

    【讨论】:

      猜你喜欢
      • 2012-01-14
      • 2013-03-11
      • 2015-11-13
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-24
      • 2012-02-07
      相关资源
      最近更新 更多