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?
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]....
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.
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)...