# Undefined method error from atom builder

**URL:** <https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987>\
**Category:** Rails\
**Created:** [July 13, 2009, 3:34am UTC](https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987 "2009-07-13T03:34:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ate50eggs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@ate50eggs](https://www.ruby-forum.com/u/ate50eggs)\
**Post date:** [July 13, 2009, 3:34am UTC](https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987/1 "2009-07-13T03:34:03Z")

</div>

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:in` **send** ’  
/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:in`entry’  
/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:in`entry’

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

---

<div class="post-metadata">

**Author:** ![ate50eggs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@ate50eggs](https://www.ruby-forum.com/u/ate50eggs)\
**Post date:** [July 13, 2009, 3:41am UTC](https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987/2 "2009-07-13T03:41:04Z")

</div>

On Jul 13, 2:12 am, Nathan B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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

---

<div class="post-metadata">

**Author:** ![ate50eggs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@ate50eggs](https://www.ruby-forum.com/u/ate50eggs)\
**Post date:** [July 18, 2009, 9:43pm UTC](https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987/3 "2009-07-18T21:43:28Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ate50eggs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/fbc32d/32.png) [@ate50eggs](https://www.ruby-forum.com/u/ate50eggs)\
**Post date:** [July 18, 2009, 10:21pm UTC](https://www.ruby-forum.com/t/undefined-method-error-from-atom-builder/171987/4 "2009-07-18T22:21:42Z")

</div>

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](http://www.marnen.org)  
removed\_email\_address@domain.invalid
