I ran into this same problem (with 'species' rather than 'equipment'
but it's the same issue) and like others in this thread, I misread the
problem:

the problem is not a routes problem, it's a scaffolding problem (the
problem is actually within the body of the generated scaffold erb
file).

In the scaffold, there are  two problems in the generated
new.html.erb:

<% form_for(@MODELNAME) do |f| %>
and at the bottom
<%= link_to 'Back', species_path %>

each of these would generate errors

In the first case, the form_for just needs a bit of help. Use the
following:

<% form_for(@MODELNAME, :url=> {:action=>'create'}) do |f| %>

In the second case, there is a specific route path_helper generated

<%= link_to 'Back', MODELNAME_index_path %>

models that have the same singluar and plural (whether genuinely
uncountable like equipment, or just because the two forms are the
same) have special name for the index path (because the plural isn't
distinguished) and you need to use that:

equipment_index_path / species_index_path

> So here is my suggestion.
>
> Do not, without a really good reason, use a Model name that doesn't
> have distinct singular/plural forms.

So I would say, you SHOULD use whatever model name is appropriate
(excepting of course ruby/rails reserved words / key concepts) even if
there is no plural distinction, but you just need to adjust the
scaffold as above (and similarly elsewhere).

This should I think be fixed in rails, and apparently there's no
ticket for it (at least I couldn't find one), so I created  a new
ticket:
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3095-generated-scaffold-for-model-with-same-plural-as-singular-gives-errors


all the best

Tim
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to