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.
On Jul 13, 2:12 am, Nathan Beyer <nbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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> > 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.
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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jul 13, 2:12 am, Nathan Beyer <nbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a simple controller that takes a request, looks up some data > > and then returns the results as either HTML orAtom. The HTML response > > works fine, but theAtomBuilderis blowing up with anundefined > >methoderrorthat I can''t figure out. It seems to be failing when the > > ActiveRecord instance is passed to the ''entry''methodand 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 > > > > >Errormessage -undefinedmethod`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.
Nathan Beyer 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 marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- undefined method `stories_path'
- How do I force link_to/form helpers to use the superclass name in the path instead subclass?
- 3.0.0rc ActionController::RoutingError No route matches
- Rails plugins new official maintainers
- Polymorphic URL helpers documentation and fixes