Auto-generated methods
Singular associations (one-to-one)
| | belongs_to |
generated methods | belongs_to | :polymorphic | has_one
------------------+------------+--------------+---------
#other | X | X | X
#other=(other) | X | X | X
#build_other() | X | | X
#create_other() | X | | X
#other.create!() | | | X
#other.nil? | X | X |
Collection associations (one-to-many / many-to-many)
| | | has_many
generated methods | habtm | has_many | :through
------------------------------+-------+----------+----------
#others | X | X | X
#others=(other,other,...) | X | X | X
#other_ids | X | X | X
#other_ids=(id,id,...) | X | X | X
#others<< | X | X | X
#others.push | X | X | X
#others.concat | X | X | X
#others.build(attributes={}) | X | X | X
#others.create(attributes={}) | X | X | X
#others.create!(attributes={})| X | X | X
#others.size | X | X | X
#others.length | X | X | X
#others.count | X | X | X
#others.sum(args*,&block) | X | X | X
#others.empty? | X | X | X
#others.clear | X | X | X
#others.delete(other,other,..)| X | X | X
#others.delete_all | X | X |
#others.destroy_all | X | X | X
#others.find(*args) | X | X | X
#others.find_first | X | |
#others.uniq | X | X | X
#others.reset | X | X | X
Explanations of some methods:
others.build(attributes = {}, …): Returns one or more new objects of the collection type that have been instantiated with attributes and linked to this object through a foreign key, but have not yet been saved.
attr_protected
Attributes named in this macro are protected from mass-assignment, such as new(attributes), update_attributes(attributes), or attributes=(attributes).
Mass-assignment to these attributes will simply be ignored, to assign to them you can use direct writer methods. This is meant to protect sensitive attributes from being overwritten by malicious users tampering with URLs or forms.
No comments :
Post a Comment