Reputation: 7451
Can any one please help to how to fetch the values of attributes from the has_many Relationship on rails
For example company is one relation and has many email
company --> email
i need to fetch email_address from those company.email
How can i do that?
company.email.email_address
Upvotes: 0
Views: 214
Reputation: 208
Try this
@company = Email_address.find(:all,params[:email_id], :include => #:user, :conditions => "email_id=#{params[:email_id].to_i} AND published=true")
Upvotes: 1
Reputation: 276
@company = Company.find(1) @company.emails.collect(&:email_address)
Upvotes: 3