Forum: Ruby on Rails Model method disappear after first page request

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.
2d5066f58b942a9a1ee429c8dc17dc46?d=identicon&s=25 blakeage (Guest)
on 2007-02-14 17:40
(Received via mailing list)
I can't figure out why model methods disappear after the first page
request?  If I restart Webrick, I can load the page once, without
error, but refresh the page, and I keep getting method missing
errors.  My code is extremely simple:

class LineItem < ActiveRecord::Base
  belongs_to :order
end

class Order < ActiveRecord::Base
  has_many :line_items
end

--> index.rhtml
<%= @line_item.order.id %>

Error is like method "order" missing for <LineItem:#29932...

This is in development mode, Rails 1.2, Windows 2000, Webrick

Help!
87d298ecabf4a78819698a036ce01a1a?d=identicon&s=25 Mark Carey (Guest)
on 2007-02-14 17:49
(Received via mailing list)
What code do you have in your controller?

M<><
2d5066f58b942a9a1ee429c8dc17dc46?d=identicon&s=25 blakeage (Guest)
on 2007-02-14 18:09
(Received via mailing list)
Nothing, except for the scaffold_resource inserted code, like
respond_to html...

It's in the index action, and I'm using the REST architecture.  My
index.rhtml source is like:
<% for acc in @user.accounts %>
  <% for line_item in acc.line_items %>
    <%= line_item.order.id %>
  <% end %>
<% end %>

Note: You can pull back the line items by account, as each LineItem
has an AccountID
This topic is locked and can not be replied to.