Possible bug in Rails 3.0.3 form_for?

I’m trying to get nested resources working, however I’ve run into a
peculiar problem which seems like it may be a bug.

I have Projects which have Analyses, or the singular versions Project &
Analysis. Here’s my routes.rb entry:

resources :projects do
resources :analyses
end

For example: /projects/2/analyses/3. The new works fine:
projects/2/analyses/new

Almost everything works, except for the analysis edit:
projects/2/analyses/3/edit

It returns the following error:

NoMethodError in Analyses#edit
undefined method `project_analyasis_path’

This is bizarre since it is trying to find analyasis which is
misspelled. Nowhere in my code is analysis or analyses misspelled as
analyasis.

Here’s my analysis _form partial:

<%= form_for [@project, @analysis] do |f| %>

if I change it to <%= form_for [@project, @analysis], :url =>
project_analysis_path(@project, @analysis) do |f| %> edit will work,
however new ceases to work.

Any ideas? Is this a bug in form_helper.rb?

On 24 January 2011 22:19, Edward S. [email protected] wrote:

For example: /projects/2/analyses/3. The new works fine:
projects/2/analyses/new

Almost everything works, except for the analysis edit:
projects/2/analyses/3/edit

It returns the following error:

NoMethodError in Analyses#edit
undefined method `project_analyasis_path

What is the name of Analyses controller class and the name of the file?
Can you show us the code around the line that fails. The error should
say which line it is on.

Colin

On Jan 24, 10:19pm, Edward S. [email protected] wrote:

It returns the following error:

NoMethodError in Analyses#edit
undefined method `project_analyasis_path

I think rails is failing to pluralize/singularize your class names.
(try pluralizing your class name from the console). If this is the
case you can add an inflection rule that will add the correct plurals
for you (there should be examples in config/initializers/inflector.rb

Fred

Frederick C. wrote in post #977382:

I think rails is failing to pluralize/singularize your class names.
(try pluralizing your class name from the console). If this is the
case you can add an inflection rule that will add the correct plurals
for you (there should be examples in config/initializers/inflector.rb

Fred

You were right! I added an entry to config/initializers/inflections.rb
and it works now.

ActiveSupport::Inflector.inflections do |inflect|
inflect.irregular ‘analysis’, ‘analyses’
end

Thanks!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs