Rails 3 2 counter cache not updating validating textbox
For example, you might have a picture model that belongs to either an employee model or a product model.
Here's how this could be declared: In designing a data model, you will sometimes find a model that should have a relation to itself.
That's followed by some tips and tricks for working with associations, and then by a complete reference to the methods and options for associations in Rails.
However, Active Record will not automatically identify bi-directional associations that contain a scope or any of the following options: association creates a one-to-one match with another model.
In database terms, this association says that this class contains the foreign key.
You are responsible for maintaining your database schema to match your associations.
In practice, this means two things, depending on what sort of associations you are creating.
If the association name is wrongly pluralized, then the inferred class will be wrongly pluralized too.