form_for resources with :singular specified

I fully suspect that I'm missing the point here somewhere so I promise I won't be offended if you tell me I'm being daft.

My application rents equipment ... not equipments. So I have the following:

  map.resources :equipment, :singular => :equipment_instance

  class Equipment < ActiveRecord::Base

  class EquipmentController < ApplicationController

The problem comes in my _form.haml partial that is used by new.haml and edit.haml:

- form_for @equipment do |f|

This gives me an error saying "Only get and post requests are allowed. (ActionController::MethodNotAllowed)"

I tried:

- form_for @equipment, equipment_instance_path(@equipment) do |f|

That gives the same error.

There has to be something better than:

- form_for @equipment, :url => (@equipment.new_record? ? equipment_path : equipment_instance_path(@equipment)), :html => (@equipment.new_record? ? { :method => :post } : { :method => :put }) do |f|

Why does Rails not introspect correctly in this case?

Bryan

Is it possible that you could avoid the problem by a better choice of model/table name? The convention is to use a name that makes the code read well in your language, in this case I presume English. So for example you may have a table called items, which contains obviously a number of items and if you find one of them it is an item. Similarly another class can define has_many :items, belongs_to :item and so on and it reads well. Equipment is not a word that fits this pattern. One cannot have an equipment or many equipment, it just does not work. An item in the table is not an equipment. As you use the term equipment_instance you could use that as the table name or there may be a better word. Think about how you or the specifier or end user would refer to a number of these objects to give you ideas.

Colin