Beginner's question


#1

Hi all,
Sorry if this question looks stupid…

In my post on edit action I have:

def edit
@post = Post.find(params[:id],:include => [:ingredients,
{:ingredients => :heb_ingredient}])
ingredients = @post.ingredients
ing = ingredients[0] # <-- ing is not nil
ei = ing.eng_ingredient # <-- ei is not nil but it’s
attrs are nil

end

This doesn’t work only when I execute on browser. However if I run all
the commands thru script/console, then all the data is correct and
present.
What can be the problem? All the models seem to be defined correctly.


#2

Sorry, the previous code was wrong, anyway the problem is the same:

def edit
@post = Post.find(params[:id],:include => [:ingredients,
{:ingredients => :eng_ingredient}])
ingredients = @post.ingredients
ing = ingredients[0] # <-- ing is not nil
ei = ing.eng_ingredient # <-- ei is not nil but it’s
attrs are nil

end