Hello, in a restful application, I am trying to create the thing mentioned int he subject: link to the association, e.g. /articles/1/comments. The "link_to ''comments'', @article.comments" doesn''t do anything good for me... I can get the result via "link_to ''comments'', @article.comments.new", but creating new object just for link generation seems wrong (also, the intention is something completely different, the paths for ''create new comment'' and ''comments'' just coincide)... I can also get it by "link_to ''comments'', url_for_article_comments( @article )", but I would like to have a shorter version (especially when used in multi-level relationships)... I am currently using Rails 2.0.1. Anybody knows the official way to do it? Could an upgrade of Rails help? izidor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 21.5.2008, at 9:52, Izidor Jerebic wrote:> > Hello, > > in a restful application, I am trying to create the thing mentioned > int he subject: link to the association, e.g. /articles/1/comments. > > The "link_to ''comments'', @article.comments" doesn''t do anything good > for me... > > I can get the result via "link_to ''comments'', > @article.comments.new", but creating new object just for link > generation seems wrong (also, the intention is something completely > different, the paths for ''create new comment'' and ''comments'' just > coincide)...Above is typo, I tried "link_to ''comments'', [@article, @article.comments.new]....> > > I can also get it by "link_to ''comments'', > url_for_article_comments( @article )", but I would like to have a > shorter version (especially when used in multi-level relationships)... > > I am currently using Rails 2.0.1. > > Anybody knows the official way to do it? Could an upgrade of Rails > help? > > > izidor > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 21.5.2008, at 9:56, Izidor Jerebic wrote:> > On 21.5.2008, at 9:52, Izidor Jerebic wrote: > >> >> Hello, >> >> in a restful application, I am trying to create the thing mentioned >> int he subject: link to the association, e.g. /articles/1/comments. >> >> The "link_to ''comments'', @article.comments" doesn''t do anything >> good for me... >> >> I can get the result via "link_to ''comments'', >> @article.comments.new", but creating new object just for link >> generation seems wrong (also, the intention is something completely >> different, the paths for ''create new comment'' and ''comments'' just >> coincide)... > > Above is typo, I tried "link_to ''comments'', [@article, > @article.comments.new].... > >> >> >> I can also get it by "link_to ''comments'', >> url_for_article_comments( @article )", but I would like to have a >> shorter version (especially when used in multi-level >> relationships)...I am confused today: link_to ''comments'', article_comments_path( @article )" is of course my code.>> >> >> I am currently using Rails 2.0.1. >> >> Anybody knows the official way to do it? Could an upgrade of Rails >> help? >> >> >> izidor >> >> >--~--~---------~--~----~------------~-------~--~----~ 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''re talking about nested resources here if I understand that right. So what sense would it make to link the comments index action for a not existing article? Or are you using a namespace article? -- 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 -~----------~----~----~----~------~----~------~--~---
Eh, I am a bit confused today... Let me try to explain... The @article exists, and Rails could get to it from association object, I presume... I would like to get /articles/1/comments in a shortes possible way. It could be programmed by taking the association object @article.comments, retrieving its parent object, and constructing path. But it doesn''t happen currently. The shortest way to get the path is "link_to ''ccc'', [@article, @article.comments.new]", but I don''t like it... The correct way is "link_to ''ccc'', article_comments_path( @article )", but it is long (especially for multi-level paths)... izidor On 21.5.2008, at 10:11, Thorsten Mueller wrote:> > You''re talking about nested resources here if I understand that right. > > So what sense would it make to link the comments index action for a > not > existing article? > Or are you using a namespace article? > -- > 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 -~----------~----~----~----~------~----~------~--~---