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: <p>
7: <b>Name</b><br />
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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
David Piehler
2008-May-29 18:49 UTC
Re: Resource routing error with the route equipment/new
David Piehler wrote:> 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 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: <p> > 7: <b>Name</b><br /> > 8: <%= f.text_field :name %> >Running "rake routes" showed something odd. Instead of "equipment", the plain GET route is shown as "equipment_index". Is there any way to override/fix this? equipment_index GET /equipment {:action=>"index", :controller=>"equipment"} formatted_equipment_index GET /equipment.:format {:action=>"index", :controller=>"equipment"} POST /equipment {:action=>"create", :controller=>"equipment"} POST /equipment.:format {:action=>"create", :controller=>"equipment"} new_equipment GET /equipment/new {:action=>"new", :controller=>"equipment"} formatted_new_equipment GET /equipment/new.:format {:action=>"new", :controller=>"equipment"} edit_equipment GET /equipment/:id/edit {:action=>"edit", :controller=>"equipment"} formatted_edit_equipment GET /equipment/:id/edit.:format {:action=>"edit", :controller=>"equipment"} equipment GET /equipment/:id {:action=>"show", :controller=>"equipment"} formatted_equipment GET /equipment/:id.:format {:action=>"show", :controller=>"equipment"} PUT /equipment/:id {:action=>"update", :controller=>"equipment"} PUT /equipment/:id.:format {:action=>"update", :controller=>"equipment"} DELETE /equipment/:id {:action=>"destroy", :controller=>"equipment"} DELETE /equipment/:id.:format {:action=>"destroy", :controller=>"equipment"} facilities GET /facilities {:action=>"index", :controller=>"facilities"} formatted_facilities GET /facilities.:format {:action=>"index", :controller=>"facilities"} POST /facilities {:action=>"create", :controller=>"facilities"} POST /facilities.:format {:action=>"create", :controller=>"facilities"} new_facility GET /facilities/new {:action=>"new", :controller=>"facilities"} formatted_new_facility GET /facilities/new.:format {:action=>"new", :controller=>"facilities"} edit_facility GET /facilities/:id/edit {:action=>"edit", :controller=>"facilities"} formatted_edit_facility GET /facilities/:id/edit.:format {:action=>"edit", :controller=>"facilities"} facility GET /facilities/:id {:action=>"show", :controller=>"facilities"} formatted_facility GET /facilities/:id.:format {:action=>"show", :controller=>"facilities"} PUT /facilities/:id {:action=>"update", :controller=>"facilities"} PUT /facilities/:id.:format {:action=>"update", :controller=>"facilities"} DELETE /facilities/:id {:action=>"destroy", :controller=>"facilities"} DELETE /facilities/:id.:format {:action=>"destroy", :controller=>"facilities"} /:controller/:action/:id /:controller/:action/:id.:format Thanks, - Dave -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David Piehler
2008-May-29 21:50 UTC
Re: Resource routing error with the route equipment/new
David Piehler wrote:> Running "rake routes" showed something odd. Instead of "equipment", the > plain GET route is shown as "equipment_index". Is there any way to > override/fix this?Nevermind, it has to be ''equipment_index'' because the plain ''equipment'' is being used by the ''show'' action. And now my first lesson in named resource routes is complete :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---