Forum: Ruby on Rails Variable.attribute returns object Class, possible association problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
75ea6b6459bd65a2e89314bf2a5bd7b6?d=identicon&s=25 Greg Bressler (gregb)
on 2017-02-07 21:20
Attachment: schema.rb (3 KB)
Attachment: line_items_index.html.erb (693 Bytes)
Attachment: line_items_controller.rb (3 KB)
Attachment: line_item.rb (458 Bytes)
Attachment: recipe.rb (874 Bytes)
Attachment: ingredient.rb (62 Bytes)
I have a cookbook app that allows users to save their favorite recipes
and on their profile page they can get a randomized weekly menu based on
their favorite recipes.

 I am trying to be able to print out the ingredients of the weekly menu,
but so far I can’t get it to print the name of the ingredient.
Currently when I try something like:

    <%= line_item.recipe.ingredient.name%>
The result is “Ingredient”.

I suspect that it might have something to do with associations, but I
can’t figure it out.  Any help would be greatly appreciated.
This topic is locked and can not be replied to.