Undefined method error from atom builder

I have a simple controller that takes a request, looks up some data
and then returns the results as either HTML or Atom. The HTML response
works fine, but the Atom Builder is blowing up with an undefined
method error that I can’t figure out. It seems to be failing when the
ActiveRecord instance is passed to the ‘entry’ method and it tries to
build the URL via the ‘polymorphic_url’ method. There is no
‘order_url’ method, field or database column, so I’m at a loss.

Error message - undefined method order_url' for #<ActionView::Base: 0x25e3560> Code snippet that's failing (line 7) - 4: 5: for order in @orders 6: 7: feed.entry(order) do |entry| 8: Stack trace of failure - /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ polymorphic_routes.rb:109:insend
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_controller/
polymorphic_routes.rb:109:in polymorphic_url' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_view/helpers/ atom_feed_helper.rb:189:inentry’
/Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:
134:in call' /Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb: 134:in_nested_structures’
/Library/Ruby/Gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in
method_missing' /Library/Ruby/Gems/1.8/gems/actionpack-2.3.2/lib/action_view/helpers/ atom_feed_helper.rb:178:inentry’

I’m running Ruby 1.8.6 on Mac OS X 10.5.7. Thanks.

On Jul 13, 2:12 am, Nathan B. [email protected] wrote:

I have a simple controller that takes a request, looks up some data
and then returns the results as either HTML or Atom. The HTML response
works fine, but the Atom Builder is blowing up with an undefined
method error that I can’t figure out. It seems to be failing when the
ActiveRecord instance is passed to the ‘entry’ method and it tries to
build the URL via the ‘polymorphic_url’ method. There is no
‘order_url’ method, field or database column, so I’m at a loss.

You’ve got an instance of order, so various bits of rails assume that
(by default) to link to that particular object the order_url helper
should be called. Usually you get this for free when you write
map.resources :orders in your routes file (although you don’t have to
create the named route via resources)

Fred

Thanks. I was missing the map.resources to that model. I didn’t add a
helper and it still seems to work. In any case, this was a “manually”
created model, instead of using the Rails script, so that’s why it was
missing for me.

Thanks again.

On Jul 12, 8:40 pm, Frederick C. [email protected]

Nathan B. wrote:
[…]

In any case, this was a “manually”
created model, instead of using the Rails script, so that’s why it was
missing for me.

No. script/generate model doesn’t generate map.resources statements.
You always have to do those yourself if you want them.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]