search for: foodallergy

Displaying 2 results from an estimated 2 matches for "foodallergy".

2006 Apr 06
4
Record retrieval in Many-to-many using :through not working
...om_id, a few other columns symptoms - id, symptom Models class Food < ActiveRecord::Base has_many :foodallergies has_many :symptoms, :through => :foodallergies end class Symptom < ActiveRecord::Base has_many :foodallergies has_many :foods, :through => :foodallergies end class Foodallergy < ActiveRecord::Base belongs_to :foods belongs_to :symptoms end In the console, when I do f = Food.find(:first), the first food item is returned. I can also retrieve a symptom that way directly from the Symptom model. But, this does not work. f = Food.find(:first) f.symptoms f.symptoms g...
2006 Apr 04
4
Help with many-to-many using :through
...om_id, a few other columns symptoms - id, symptom Models class Food < ActiveRecord::Base has_many :foodallergies has_many :symptoms, :through => :foodallergies end class Symptom < ActiveRecord::Base has_many :foodallergies has_many :foods, :through => :foodallergies end class Foodallergy < ActiveRecord::Base belongs_to :foods belongs_to :symptoms end I have a JournalEntry model that stores foods and symptoms as comma-seperated strings. Upon record creation in the JournalEntry, I want to parse the foods and symptoms and create a many to many relationship between them. I do t...