Ruby on rails: singular resource and form_for

petRUShka picture petRUShka · Sep 17, 2010 · Viewed 14.9k times · Source

I want user to work with only one order connected to user's session. So I set singular resource for order

routes.rb:

resource :order

views/orders/new.html.erb:

<%= form_for @order do |f| %>
   ...
<% end %>

But when I open the new order page I get an error:

undefined method `orders_path`

I know, that I can set :url => order_path in form_for, but what is the true way of resolving this collision?

Answer

mckeed picture mckeed · Sep 17, 2010

Unfortunately, this is a bug. You'll have to set the url like you mention.

= form_for @order, :url => orders_path do |f|