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? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 January 2011 22:19, Edward Stembler <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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’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> > 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? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jan 24, 10:19 pm, Edward Stembler <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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’ >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> -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung 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 > > FredYou 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! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.