search for: user_newscategory

Displaying 1 result from an estimated 1 matches for "user_newscategory".

2006 Jul 03
0
Modelling Relationships as objects
...scriptions has_many :users, :through => :subscriptions end class Subscription < ActiveRecord::Base belongs_to :user belongs_to :news_category end User and NewsCategory(2 tables in database) have m:n relation and hence they would require another db table to represent the relationship.(User_NewsCategory); now they r 2 ways to model these objects and relations in Rails, 1. Use habtm with 2 models for 2 db tables. 2. Use has_many :through with 3 models and 3 db tables. 2nd would be of choice if we want the relationship to be converted in to an object. This is fine with m:n relationships, but how a...