Topic: Multiple relationship

Hello All,
I am newbie to Ruby and i am just trying to fetch records from two different tables. Table structure are

label2_label : ID (int) Primary Key, l2_label (string), l1id (int) (Foreign Key with other table), description

level2_description: ID (int) Primary Key, pid -- (Foreign Key with other table), l2id (Foreign Key label2_label table), description

I want to fetch record from both the table and on relation with ID(level2_label) => l2id(level2_description).

I am using common partial for add so in case of add i would like to display description of level2_label and in case of edit i would like to display description of level2_description. To achieve this i want to have relationship and fetch the record.

In controller level2_label i have given relationship like
has_many :cqm_level2_descriptions, :foreign_key => l2id,:dependent => :destroy
and in level2_description
belongs_to :cqm_level2_labels;
I used CqmLevel2Label.find_all_by_l1id(1) to get values from both the tables but it is not fetching it.

Require help :-)

Last edited by ashinaidu (2011-03-11 03:10:26)