forked from a2ikm/activerecord-and-mongoid-sample
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
== activerecord-and-mongoid-sample | ||
|
||
# activerecord-and-mongoid-sample | ||
|
||
We can use ActiveRecord and Mongoid in one app. | ||
This Rails3 app is that sample. | ||
|
||
|
||
=== Installing Mongoid | ||
## Installing Mongoid | ||
|
||
Add 'bson_ext' and 'mongoid' to Gemfile, and run `bundle`. | ||
Then run `rails g mongoid:config` to generate a configuration file for Mongoid. | ||
|
||
|
||
=== Creating Model Files | ||
## Creating Model Files | ||
|
||
After installing mongoid, 'model' generator is for Mongoid. | ||
|
||
$ r g model todo_log title:string done:boolean | ||
invoke mongoid | ||
create app/models/todo_log.rb | ||
<pre> | ||
$ r g model todo_log title:string done:boolean | ||
invoke mongoid | ||
create app/models/todo_log.rb | ||
</pre> | ||
|
||
So, when you're creating an ActiveRecord model file, | ||
use 'active_record:model' generator. | ||
|
||
$ r g active_record:model todo title:string done:boolean | ||
create db/migrate/20110730071022_create_todos.rb | ||
create app/models/todo.rb | ||
|
||
|
||
<pre> | ||
$ r g active_record:model todo title:string done:boolean | ||
create db/migrate/20110730071022_create_todos.rb | ||
create app/models/todo.rb | ||
</pre> |