Use development ID for independent Rails

Source: Internet
Author: User

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:

  1. Development:
  2. Host: localhost
  3. Database: personal_center_development
  4. Test:
  5. Host: localhost
  6. Database: personal_center_test 
  7.  
  8. # Set these environment variables on your prod server
  9. Production:
  10. Host: <% = ENV ['Upload ID _ host'] %>
  11. Port: <% = ENV ['Upload ID _ port'] %>
  12. Username: <% = ENV ['Upload ID _ username'] %>
  13. Password: <% = ENV ['Your ID _ password'] %>
  14. Database: <% = ENV ['Upload ID _ database'] %>

The following describes how to load:

  1. Require'Upload id'
  2. ENV ['Upload ID _ env'] ='Development'
  3. # Replace it with the producer ID. yml directory you just created
  4. Upload ID. load! ("../Config/consumer ID. yml")
  5. # Optional. You can directly load the model if you want to reuse it.
  6. Dir. Glob ("# {File. dirname (_ FILE _)}/../app/models/*. rb")Do| Lib |
  7. Require lib
  8. End
  9. # Try to output OK
  10. 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/

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.