Variable.attribute returns object Class, possible association problem

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.