Ruby on Rails
has_many (Version #36)

The has_many association provides a way to access a one way relation between two tables.

Examples of this:sd

  • Companies database, where a company may have many accounts.
  • Forum System, where a category has many forums, which has many topics.

Example Forum

See ForumExample.

See Also

Notes

The finder_sql option in has_many should be in single quotes if you want inline variables (e.g. ‘SELECT * FROM something WHERE user_id = #{id}’) to be evaluated properly!

The has_many association provides a way to access a one way relation between two tables.

Examples of this:sd

  • Companies database, where a company may have many accounts.
  • Forum System, where a category has many forums, which has many topics.

Example Forum

See ForumExample.

See Also

Notes

The finder_sql option in has_many should be in single quotes if you want inline variables (e.g. ‘SELECT * FROM something WHERE user_id = #{id}’) to be evaluated properly!