Model method disappear after first page request


#1

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!


#2

What code do you have in your controller?

M<><


#3

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