I’m having an issue with resource routing after running a “ruby
script/generate scaffold equipment” command. I did not make any changes
to the equipment model/controller/views after running this.
The full command I ran (all one line) …
ruby script/generate scaffold equipment
name:string description:text contact:text keywords:string
created_at:datetime created_by:integer
updated_at:datetime updated_by:integer
IN config/routes.rb I have the following placed above the default routes
…
map.resources :equipment
–
The following routes work (I added ID#1 directly into the database) …
/equipment
/equipment/1
/equipment/1/edit
The following route fails …
/equipment/new
–
When going to /equipment/new …
ActionController::RoutingError in Equipment#new
Showing equipment/new.html.erb where line #5 raised:
equipment_url failed to generate from {:controller=>“equipment”,
:action=>“show”} - you may have ambiguous routes, or you may need to
supply additional parameters for this route. content_url has the
following required parameters: [“equipment”, :id] - are they all
satisfied?
Extracted source (around line #5):
2:
3: <%= error_messages_for :equipment %>
4:
5: <% form_for(@equipment) do |f| %>
6:
7: Name
8: <%= f.text_field :name %>
–
I’ve tried adding the following to inflections.rb (one at a time, not
simultaneously) even though I think ‘equipment’ is already in the
standard rails inflections code, and nothing changed …
Inflector.inflections do |inflect|
inflect.uncountable %w( equipment )
end
Inflector.inflections do |inflect|
inflect.irregular ‘equipment’, ‘equipment’
end
–
I also tried changing routes.rb to the following, which caused
equipment/new to work but the other three routes to fail …
map.resources :equipment, :singular => :equipment_instance
–
Any ideas on what could be happening?
THANKS!
- Dave