3

当我尝试rails g bootstrap:themed Associations在终端中运行时会发生这种情况:

C:/Users/ruby/.pik/rubies/Ruby-193-p327/lib/ruby/gems/1.9.1/gems/twitter-bootstrap-rails-2.1.9/lib/generators/bootstrap/themed/themed_generator.rb:87:in `block in retrieve_columns': undefined method `columns' for Association:Class (NoMethodError)

它似乎无法正常工作,我尝试了很多方法,到处搜索,从未成功。我正在使用Mongo。

4

1 回答 1

7

我刚刚得到完全相同的错误。我创建了两个相同的项目——一个有 mongoid,一个没有。我只收到关于 mongoid 项目的错误。

找到了似乎可以解决问题的解决方法:

删除文件中对 ActiveRecord(第 87 行附近)的引用:

/home/ubuntu/.rvm/gems/ruby-1.9.3-p327/bundler/gems/twitter-bootstrap-rails-b8b7eb22614a/lib/generators/bootstrap/themed/themed_generator.rb

我变了 ...

  def retrieve_columns
    if defined?(ActiveRecord)
      rescue_block ActiveRecord::StatementInvalid do
        @model_name.constantize.columns
      end
    else
      rescue_block do
        @model_name.constantize.fields.map {|c| c[1] }
      end
    end
  end

对此...

  def retrieve_columns
      rescue_block do
        @model_name.constantize.fields.map {|c| c[1] }
      end
  end

为了让视图正常工作,我需要确保我的模型类有一个 created_at 字段不是 nil(或者编辑生成的视图)。

希望这可以帮助。

PS:哇......似乎你已经在 Windows 上运行了 twitter-bootstrap-rails - 我不知道这是可能的!

于 2012-12-29T03:09:56.740 回答