Reputation: 4762
I'm using rails3 edge and mongoid 2beta6 with ruby 1.9.2-head.
How can I manually change the table name, just like set_table_name for ActiveRecord? For example my model Signup should use the table "users" for storage, not "signups".
Another question is how to implement the bevahior of attr_accessible AR provides?
Thanks, Corin
Upvotes: 2
Views: 2963
Reputation: 3139
Pretty simple :)
Change:
class Pictures
self.collection_name = 'photos'
end
To:
class Pictures
store_in collection: 'photos'
end
Source: https://docs.mongodb.com/mongoid/current/tutorials/mongoid-documents/#storage
Upvotes: 7
Reputation: 3593
The link mentioned by Dan Healy was changed to http://mongoid.org/en/mongoid/docs/documents.html.
Upvotes: 0
Reputation: 4507
With mongoid, as far as I know attr_accessible
is ignored.
Only attributes that you declare with field
will be persisted, however if they are passed as an attribute, you can use attr_accessor
to make sure those will not be persist (typically :password as an example).
Alex
Upvotes: 1