NoSQL has many advantages,
Just
1. store any objects, images, files, and so on.
2. The same object storage is not restricted.
That's enough for me to hug.
So, go to ruby and check that there is a feeling that the consumer ID will gradually replace the consumer Mapper. Next I will use the consumer ID to make a record independently:
For yml configuration, if you want to use the rails project, you can also:
- Development:
- Host: localhost
- Database: personal_center_development
- Test:
- Host: localhost
- Database: personal_center_test
-
- # Set these environment variables on your prod server
- Production:
- Host: <% = ENV ['Upload ID _ host'] %>
- Port: <% = ENV ['Upload ID _ port'] %>
- Username: <% = ENV ['Upload ID _ username'] %>
- Password: <% = ENV ['Your ID _ password'] %>
- Database: <% = ENV ['Upload ID _ database'] %>
The following describes how to load:
- Require'Upload id'
- ENV ['Upload ID _ env'] ='Development'
- # Replace it with the producer ID. yml directory you just created
- Upload ID. load! ("../Config/consumer ID. yml")
- # Optional. You can directly load the model if you want to reuse it.
- Dir. Glob ("# {File. dirname (_ FILE _)}/../app/models/*. rb")Do| Lib |
- Require lib
- End
- # Try to output OK
- Puts User. all. size
Note that the above is hard to understand: MONGOID_ENV. In fact, it is added to support rails, sinatra, and so on. We can only do this when using it independently. You can try to see.
Note that the consumer ID must be at least 2.4.3 or above. There are many problems with the previous versions, and various exceptions may occur.
The good thing is that the consumer ID team is awesome, and the issues mentioned quickly responds.
At this point, the problem has been solved. If you have the problem, try again.
The official homepage of consumer ID is: http://mongoid.org/