Hello, i have a problem, had a table called news and other called news_images, the first é for save news and other for save url for images associated with news. Make migrations for each table manual and db:migrate after that i run scaffold for news, and generate model for news_image... put has_many and belongs_to in file_column on news_image model and ok.... when i try access page for new News i get this error: ActionController::RoutingError in News#new news_url failed to generate from {:action=>"show", :controller=>"news"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["news", :id] - are they all satisfied? Extracted source (around line #5): 2: 3: <%= error_messages_for :news %> 4: 5: <% form_for(@news) do |f| %> I don''t understand why, i don''t had any other route with same name in routes.rb, i can''t had tables with names like news? Obrigado . --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Some one can help? On Jan 13, 2:36 am, Daniel Lopes <danielvlo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, i have a problem, had a table called news and other called > news_images, > the first é for save news and other for save url for images associated > with news. > Make migrations for each table manual and db:migrate after that i run > scaffold for news, and generate model for news_image... put has_many > and belongs_to in file_column on news_image model and ok.... when i > try access page for new News i get this error: > > ActionController::RoutingError in News#new > news_url failed to generate from > {:action=>"show", :controller=>"news"} - you may have ambiguous > routes, or you may need to supply additional parameters for this > route. content_url has the following required parameters: > ["news", :id] - are they all satisfied? > > Extracted source (around line #5): > > 2: > 3: <%= error_messages_for :news %> > 4: > 5: <% form_for(@news) do |f| %> > > I don''t understand why, i don''t had any other route with same name in > routes.rb, i can''t had tables with names like news? > > Obrigado .--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jean-François Trân
2008-Jan-13 17:51 UTC
Re: Strange error.... ActionController::RoutingError
Daniel Lopes :> Hello, i have a problem, had a table called news and other called > news_images, > the first é for save news and other for save url for images associated > with news. > Make migrations for each table manual and db:migrate after that i run > scaffold for news, and generate model for news_image... put has_many > and belongs_to in file_column on news_image model and ok.... when i > try access page for new News i get this error: > > ActionController::RoutingError in News#new > news_url failed to generate from > {:action=>"show", :controller=>"news"} - you may have ambiguous > routes, or you may need to supply additional parameters for this > route. content_url has the following required parameters: > ["news", :id] - are they all satisfied?The word news is uncountable, so you have to specify a :singular option with map.resources. see : http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-names-in-restful-routes -- Jean-François. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Understand Jean, thanks. On Jan 13, 3:51 pm, "Jean-François Trân" <jft...-HujFcYLiWL6M4zKIHC2jIg@public.gmane.org> wrote:> Daniel Lopes : > > > Hello, i have a problem, had a table called news and other called > > news_images, > > the first é for save news and other for save url for images associated > > with news. > > Make migrations for each table manual and db:migrate after that i run > > scaffold for news, and generate model for news_image... put has_many > > and belongs_to in file_column on news_image model and ok.... when i > > try access page for new News i get this error: > > > ActionController::RoutingError in News#new > > news_url failed to generate from > > {:action=>"show", :controller=>"news"} - you may have ambiguous > > routes, or you may need to supply additional parameters for this > > route. content_url has the following required parameters: > > ["news", :id] - are they all satisfied? > > The word news is uncountable, so you have to specify a > :singular option with map.resources. > > see :http://somethinglearned.com/articles/2007/03/19/how-to-uncountable-na... > > -- Jean-François.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello all! I still don''t understand, what to do in news/edit.html.erb when I try to get /news/1/edit (news with this id exists, of course) i see following: NoMethodError in News#edit Showing news/edit.html.erb where line #9 raised: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.to_sym Extracted source (around line #9): 6: <div class="errors"> 7: <%= error_messages_for :news %> 8: </div> 9: <% form_for(@news) do |f| %> link to edit looks like: <%= link_to ''Edit'', edit_news_instance_path(news), :class=>"button long" %> In routes.rb: map.resources :news, :singular => ''news_instance'' All other are works, except edit... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You aren''t defining @news in your edit method definition in your news controller On Jan 20, 2008 9:05 PM, Bregor <pipopolam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello all! > > I still don''t understand, what to do in news/edit.html.erb > > when I try to get /news/1/edit (news with this id exists, of course) i > see following: > > > NoMethodError in News#edit > > Showing news/edit.html.erb where line #9 raised: > > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.to_sym > > Extracted source (around line #9): > > 6: <div class="errors"> > 7: <%= error_messages_for :news %> > 8: </div> > 9: <% form_for(@news) do |f| %> > > > > link to edit looks like: <%= link_to ''Edit'', > edit_news_instance_path(news), :class=>"button long" %> > > In routes.rb: > > map.resources :news, :singular => ''news_instance'' > > All other are works, except edit... > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Actually the problem is not that @news is not defined in the edit action (it might be an additional problem) The way I see it, he :singular option is only used to create the the url-generation methods for the resource (e.g. edit_news_instance_path, etc.) This option however is not used by the form_for @news call to deduct the name of the url-generation-method. It just gets the singular class name of the News class from the inflections, hence instead of edit_news_instance_path, edit_news_path is called, which, of course, does not exist. A workaround might be specifying the :url option in form_for, although I''ve had trouble with this, too, at least when using namespaced resources. I hope this helps On 20 Jan., 23:57, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You aren''t defining @news in your edit method definition in your news > controller > > On Jan 20, 2008 9:05 PM, Bregor <pipopo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hello all! > > > I still don''t understand, what to do in news/edit.html.erb > > > when I try to get /news/1/edit (news with this id exists, of course) i > > see following: > > > NoMethodError in News#edit > > > Showing news/edit.html.erb where line #9 raised: > > > You have a nil object when you didn''t expect it! > > The error occurred while evaluating nil.to_sym > > > Extracted source (around line #9): > > > 6: <div class="errors"> > > 7: <%= error_messages_for :news %> > > 8: </div> > > 9: <% form_for(@news) do |f| %> > > > link to edit looks like: <%= link_to ''Edit'', > > edit_news_instance_path(news), :class=>"button long" %> > > > In routes.rb: > > > map.resources :news, :singular => ''news_instance'' > > > All other are works, except edit... > > -- > Ryan Bigghttp://www.frozenplague.net > Feel free to add me to MSN and/or GTalk as this email.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel Lopes wrote:> Hello, i have a problem...In file: your_app_name\config\initializers\inflections.rb add string: inflect.uncountable %w( news ) and read comments -- 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 -~----------~----~----~----~------~----~------~--~---
me wrote:> In file: > your_app_name\config\initializers\inflections.rb > add string: inflect.uncountable %w( news ) > and read commentsMy appologies, add : Inflector.inflections do |inflect| inflect.uncountable %w( news ) end -- 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 -~----------~----~----~----~------~----~------~--~---