database - Rails 4.0 has_many :through associations, how to pull fields via id? -


i new rails , been playing around creating web app cooking, recipes, etc. work through learning new things. have gotten bit stuck on 1 particular aspect.

i have 3 tables set work together: lessons, preparations, , ingredients.

my models set this:

class lesson < activerecord::base   has_many :preparations   has_many :ingredients, through: :preparation end  class preparation < activerecord::base   belongs_to :lesson   has_many :ingredients end  class ingredient < activerecord::base   belongs_to :preparation   belongs_to :lessons, through: :preparation end 

in lesson show view, want show name of ingredient. can seem ingredient_id in preparation table link ingredients. can view display integer (the ingredient_id) not name. i've tried bunch of things, cannot seem access ingredients table.

any on how configured correctly?

thanks.


Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -