3

This occurs when I try to run rails g bootstrap:themed Associations in my terminal:

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)

It just can't seem to work, I've tried many ways, searched everywhere, never succesful. I'm using Mongo.

1 Answers1

7

I just got exact same error. I created two identical project - one with mongoid and one without. I only get the error on the mongoid project.

Found this workaround that seems to solve the problem:

Remove references to ActiveRecord (around line 87) in the file:

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

I changed ...

  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

to this ...

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

To get the views working I needed to make sure that my model class had a created_at field that wasn't nil (alternatively edit the generated views).

Hope this helps.

PS: Wow ... it seems you've got twitter-bootstrap-rails working on windows - I didn't know that was possible!

Morten Grum
  • 962
  • 1
  • 10
  • 25
  • 1
    Yeah heheh now I'm using Ubuntu too... I actually got it to work by downgrading twitter-bootstrap-rails to '2.0.2', but maybe it isn't a permanent fix so I'll try your fix! Thank you very much! – Mário Turolla Ribeiro Dec 30 '12 at 03:43
  • 2
    Cool - good to hear. I'll send the link to twitter-boostrap-rails maintainers so they can find a permanent solution independent of ActiveRecord. – Morten Grum Dec 30 '12 at 11:21