bootstrap:主题错误的常量NameError - > const_defined?

时间:2012-03-18 14:59:35

标签: ruby-on-rails twitter-bootstrap

尝试使用Rails 3.2.2运行以下命令,切换到3.2.1并尝试使用另一台计算机来查看它是否与核心/操作系统相关。

我试试:

rails g bootstrap:themed events

我明白了:

.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:229:in `const_defined?': wrong constant name event (NameError)
    from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:229:in `block in constantize'
    from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:228:in `each'
    from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/inflector/methods.rb:228:in `constantize'
    from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/activesupport-3.2.1/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
    from /Users/charleyhine/.rvm/gems/ruby-1.9.3-p0/gems/twitter-bootstrap-rails-2.0.4/lib/generators/bootstrap/themed/themed_generator.rb:58:in `columns'
    from (erb):6:in `template'

2 个答案:

答案 0 :(得分:6)

无需降级宝石版本。相反,只需改变:

rails g bootstrap:themed events

为:

rails g bootstrap:themed Events

您需要将模型名称大写并复数化,这是愚蠢的,但它可以正常工作

答案 1 :(得分:4)

我得到了同样的错误。在搜索类似的错误之后 - 我认为它必须是最新版本的bootstrap的问题,因为我之前没有收到此错误。

我在2.0.4版本中遇到了错误。 Gemfile中的以下行后跟“bundle install”解决了它。

gem'twitter-bootstrap-rails','2.0.2'