Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails railties gem error "undefined method: 'less'"

I've just recently updated my rails app's gems with gem update and bundle update. When I tried to test it out with rails s it gives me this error:

/Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configuration.rb:85:inmethod_missing': undefined method less' for #<Rails::Application::Configuration:0x0000010308a300> (NoMethodError)

The rest of the error message goes like this:

from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/twitter-bootstrap-rails-2.1.6/lib/twitter/bootstrap/rails/engine.rb:15:in `block in <class:Engine>'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/Richard/Code/Rails/rgsimms/config/environment.rb:5:in `<top (required)>'
    from /Users/Richard/Code/Rails/rgsimms/config.ru:4:in `require'
    from /Users/Richard/Code/Rails/rgsimms/config.ru:4:in `block in <main>'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/Richard/Code/Rails/rgsimms/config.ru:1:in `new'
    from /Users/Richard/Code/Rails/rgsimms/config.ru:1:in `<main>'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
    from /Users/Richard/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Is this an error with the Twitter Bootstrap gem? I'm still learning so how would I get this fixed? Any help is awesome.

like image 344
Tamachan87 Avatar asked Nov 08 '12 07:11

Tamachan87


1 Answers

The twitter bootstrap gem depends on the less gem. From the docs:

gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"

I've personally found it easier for twitter bootstrap to just dump the files from the official site into the vendor/assets directory. Updating from the gem is marginally easier than by hand, but when updating bootstrap, you kind of want to do it "by hand" and check it all out "by eye" anyway - I prefer the extra effort, to ensure it does not get done lightly. Also, it is very hard to remove certain (for example) responsive portions from the gem, without (as far as I could tell) "unspecifying" the styles. The responsive stuff changes, from version to version, in terms of size, so you can't just rely on it all working. I really can't see any advantage to using the gem.

Update

There is now an official gem for this, which I recommend checking out: https://github.com/twbs/bootstrap-sass

like image 128
Brad Werth Avatar answered Nov 16 '22 01:11

Brad Werth