Forum: Ruby on Rails Beginner's question

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.
3c077c6c3e783e89a22778699d749d93?d=identicon&s=25 Val Ko (valk)
on 2009-02-26 02:34
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.
3c077c6c3e783e89a22778699d749d93?d=identicon&s=25 Val Ko (valk)
on 2009-02-26 02:39
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
This topic is locked and can not be replied to.