1

I am trying out mongodb with Rails 3. after following instructions from mongomapper's site and a few others, i haven't been able to solve one small issue...

No value provided for required options '--orm'

I added a file mongo.rb in my config folder to make stuff tick

MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = "cobboc_#{Rails.env}"

if defined?(PhusionPassenger)
    PhusionPassenger.on_event(:starting_worker_process) do |forked|
    MongoMapper.connection.connect if forked
  end
end

4 Answers 4

2

The mongo.rb file should be in config/initializers and contain:

require 'mongo_mapper' # loading mongo_mapper
MongoMapper.connection = Monog::Connection.new # localhost and port 27017 are the default values
MongoMapper.database = "cobboc_#{Rails.env}"

The Passenger extension is already done in the MongoMapper code.

If you'd like to use the database.yml file for configuration you can do:

require 'mongo_mapper'
db_config = YAML::load(File.read("#{Rails.root}/config/database.yml"))

if db_config[Rails.env] && db_config[Rails.env]['adapter'] == 'mongodb'
  mongo_config = db_config[Rails.env]
  MongoMapper.connection = Mongo::Connection.new(mongo_config['host'])
  MongoMapper.database = mongo_config['database']
end
Sign up to request clarification or add additional context in comments.

1 Comment

well i still cant use the generators... here is what i am using rails g model user --skip-migration and this is the error No value provided for required options '--orm'
1

The project rails3-generators provides MongoMapper model generators to solve your issue. Require the gem in your Gemfile.

# Gemfile
gem 'rails3-generators'

Note, the Rails 3 generators have moved to the mongo_mapper gem

Comments

1

You didn't specify where you were getting the "orm" error

If it was in the "generate model" case you could call the following:

sudo gem install rails3-generators

rails generate model Book --skip-migration --orm=mongomapper

Comments

0

I was running:

$ rails generate scaffold project name:string

>> No value provided for required options '--orm'

Solution:

  1. Add rails3-generators to Gemfile
  2. $ rails g scaffold project name:string --skip-migration --orm=mongomapper

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.