search for: magazine_id

Displaying 3 results from an estimated 3 matches for "magazine_id".

2006 Apr 11
3
Validations and has_many :through (Join Models)
...Many to Many Relationships Where the Relationship Iteself Has Data". Here are the tables: create_table :magazines do |t| t.column :title, :string end create_table :readers do |t| t.column :name, :string end create_table :subscriptions do |t| t.column :reader_id, :integer t.column :magazine_id, :integer t.column :last_renewal_on, :date t.column :length_in_issues, :integer end And here are the models: class Subscription < ActiveRecord::Base belongs_to :reader belongs_to :magazine end class Reader < ActiveRecord::Base has_many :subscriptions has_many :magazines, :throu...
2006 Jul 27
0
CRUD, REST and associations
...the editing form (_form.rhtml when spit out by the scaffold generator), I display a table of checkboxes and magazines where subscriptions are shown and can''t be changed. <!-- hidden field, to get a request param, even if no checkbox is selected --> <%= hidden_field_tag reader[magazine_ids][]'', '''' %> <table> <tr> <td></td> </tr> <% for magazine in reader.magazines %> <tr> <td><%= check_box_tag ''reader[magazine_ids][]'', magazine.id, @reader.subscribed_to?(ma...
2006 Jan 21
7
n-way joins
Hi, I''m somewhat of a Rails newbie and am trying to understand how to formulate n-way (3 or 4 way) joins in Rails (where the join tables contain extra data as well.) Let me give you my basic entities: foos id - pk name - unique bars id - pk name - unique bazs id - pk name - unique frozs id - pk name - unique then i have two separate join tables: foos_bars_bazs - 3 way join