Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Typical config/setup without Rails, and other questions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Darren Schnare  
View profile  
 More options Apr 21 2012, 12:43 pm
From: Darren Schnare <schnar...@gmail.com>
Date: Sat, 21 Apr 2012 09:43:05 -0700 (PDT)
Local: Sat, Apr 21 2012 12:43 pm
Subject: Typical config/setup without Rails, and other questions

Hey guys,

I love MongoMapper, but as a new Ruby user I'm finding it challenging to
find information regarding proper configuration/setup. I'm not interested
in using Rails, so I'm looking for documentation on how to get started
without Rails. I've tried digesting the source code on GitHub, but this is
about as fun as trying to shave with a butter knife =)

If anyone can help me out with the following it would be greatly
appreciated:

1) What files are required/recommended for configuration (database.yml,
mongo.yml, mongo_mapper.yml, etc.) and where should those files be located?
2) Now that :index is deprecated for keys, what is the best practice for
creating indexes (i.e. Rake, class method in the model, db/indexes.rb --
where/how does this get loaded? etc.)?
3) What are all the ways to create/delete documents (i.e. new, create,
create!, save, save!, delete, destroy, etc.) and what are the pre/post
conditions of each method? I understand most of these already but if I can
get the definitive documentation on this then that would great.
4) I've started using the documentation on Yard, but there don't seem to be
any documentation for any of the methods. Is there a better place to find
this information?

Thanks in advance! Keep up the great work!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Lawver  
View profile  
 More options Apr 22 2012, 11:28 am
From: Kevin Lawver <law...@gmail.com>
Date: Sun, 22 Apr 2012 11:28:33 -0400
Local: Sun, Apr 22 2012 11:28 am
Subject: Re: [MongoMapper] Typical config/setup without Rails, and other questions

The most important setup step is setting MongoMapper.connection.  It should look something like this:

MongoMapper.connection = Mongo::Connection.new('localhost', 27017)
MongoMapper.database = "myapp_development"

If you're connecting to a replica set, that's going to look a little different, but that should get you started.  That should happen in your code after requiring mongo_mapper but before you try to use it.

If you're not using Rails or have a lot of complex configuration, then that will do you.  Other answers below...

On Apr 21, 2012, at 12:43 PM, Darren Schnare wrote:

> Hey guys,

> I love MongoMapper, but as a new Ruby user I'm finding it challenging to find information regarding proper configuration/setup. I'm not interested in using Rails, so I'm looking for documentation on how to get started without Rails. I've tried digesting the source code on GitHub, but this is about as fun as trying to shave with a butter knife =)

> If anyone can help me out with the following it would be greatly appreciated:

> 1) What files are required/recommended for configuration (database.yml, mongo.yml, mongo_mapper.yml, etc.) and where should those files be located?
> 2) Now that :index is deprecated for keys, what is the best practice for creating indexes (i.e. Rake, class method in the model, db/indexes.rb -- where/how does this get loaded? etc.)?

ensure_index is there.  I usually create a method in each class called self.create_indexes that has all my ensure_index calls.  That's probably not the best way, but it works for me.

> 3) What are all the ways to create/delete documents (i.e. new, create, create!, save, save!, delete, destroy, etc.) and what are the pre/post conditions of each method? I understand most of these already but if I can get the definitive documentation on this then that would great.

It all depends on what you need.  I usually use create, which will return 'false' if it fails.  create! raises an error if it fails. The docs have descriptions of the callbacks: http://mongomapper.com/documentation/plugins/callbacks.html

> 4) I've started using the documentation on Yard, but there don't seem to be any documentation for any of the methods. Is there a better place to find this information?

Try this: http://mongomapper.com/documentation/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Darren Schnare  
View profile  
 More options Apr 22 2012, 1:47 pm
From: Darren Schnare <schnar...@gmail.com>
Date: Sun, 22 Apr 2012 10:47:44 -0700 (PDT)
Local: Sun, Apr 22 2012 1:47 pm
Subject: Re: [MongoMapper] Typical config/setup without Rails, and other questions

Thanks for your help Kevin.

RE: Config/setup:
I'm currently using some boilerplate code from the Ruby Grape project on
GitHub ( https://github.com/intridea/grape ) to configure MongoMapper. It's
working well, but I have no idea what configuration settings are even
available for MongoMapper. For the time being I'll just leave it as is.

RE: Indexes
The technique you describe does indeed seem to be the best approach I've
seen so far. I've come across a post describing a technique that leverages
the class-method approach and Rake to ensure indexes are created:
http://technicaldebt.com/?p=1089. I'll likely do something like you suggest
and what is in the post I mentioned.

RE: Document creation
This makes sense, thanks for the help. Don't know why I didn't quite get it
the first time I read the source code.

RE: Documentation
I'm familiar with the documentation pages on mongomapper.com, but they are
more of a reference/guide than the documentation I was looking for. No
worries, I'll suck it up and continue reading through the source.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian Hempel  
View profile  
 More options Apr 22 2012, 3:06 pm
From: Brian Hempel <plasticchic...@gmail.com>
Date: Sun, 22 Apr 2012 15:06:17 -0400
Local: Sun, Apr 22 2012 3:06 pm
Subject: Re: [MongoMapper] Typical config/setup without Rails, and other questions

> 1) What files are required/recommended for configuration (database.yml, mongo.yml, mongo_mapper.yml, etc.) and where should those files be located?

I started some doc updates for configuring MongoMapper...~75% complete. Should probably finish those...

Brian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jon Kern  
View profile  
 More options Apr 26 2012, 8:39 am
From: Jon Kern <jonker...@gmail.com>
Date: Thu, 26 Apr 2012 08:39:20 -0400
Local: Thurs, Apr 26 2012 8:39 am
Subject: Re: [MongoMapper] Typical config/setup without Rails, and other questions
I don't have the definitive answer... and the examples are a bit dated... but you can see some free-standing ruby/MM/mongo examples described on my blog and you can see example code on my github: https://github.com/JonKernPA/mongo_examples.
jon

blog: http://technicaldebt.com
twitter: http://twitter.com/JonKernPA

Brian Hempel said the following on 4/22/12 3:06 PM:
1) What files are required/recommended for configuration (database.yml, mongo.yml, mongo_mapper.yml, etc.) and where should those files be located?

I started some doc updates for configuring MongoMapper...~75% complete. Should probably finish those...

Brian




 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »