0
votes

I am trying to integrate twitter/bootstrap in my very first rails app (followed this article http://www.opinionatedprogrammer.com/2011/11/twitter-bootstrap-on-rails/) and now I get this error which I am unable to understand/resolve.


    new-host:Talker Talker$ rails s
=> Booting Thin
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Projects/Talker/config/environment.rb:4:in <top (required)>': undefined methodInitialize' for Rails:Module (NoMethodError)
    from /Projects/Talker/config.ru:4:in require'
    from /Projects/Talker/config.ru:4:inblock in '
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:in instance_eval'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize'
    from /Projects/Talker/config.ru:1:in new'
    from /Projects/Talker/config.ru:1:in'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:in eval'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/builder.rb:40:inparse_file'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:200:in app'
    from /.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:46:inapp'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:301:in wrapped_app'
    from /.rvm/gems/ruby-1.9.2-p318/gems/rack-1.4.1/lib/rack/server.rb:252:instart'
    from /.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in start'
    from /.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:55:inblock in '
    from /.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in tap'
    from /.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:50:in'
    from script/rails:6:in require'
    from script/rails:6:in'
This is how my environments.rb looks like

require File.expand_path('../application', FILE)
Rails.Initialize.run do |config|
config.gem 'mongo'
config.gem "mongo_mapper"
end
Talker::Application.initialize!

I am very new to rails so any help/direction is highly appreciated!

2

2 Answers

1
votes

When following naren's instructions, have you removed the Rails.Initialize.run block from the environment.rb file? I know this probably may sound silly :)

Also, from the second error, I gather that you might be using Mongo HQ and if it is hosted on Heroku, they have a pretty detailed instruction manual on configuring your DB. Heroku MongoHQ Dev Center. Two things to check in your app:

  1. Is the MongoDB url (Mongo HQ's url) is configured properly? This is because, the second error says that there may be a problem with the link itself.

  2. Newer version of rails (3 and above) do not allow the config.gem syntax in the environment block. Rather, you need to add a initializer file in config/initializers. More on this on the MongoDB Documentation for Rails 3 section.

Hope this helps.

1
votes

I think you do not need to specify config.gem in Rails.Initialize. In your Gemfile under project root directory specify the gems. You can remove the above

gem "mongo"
gem "mongo_mapper"

Then install gems using bundle install. Now you should be having the gems

Please try restarting after removing the Rails.Initialize block