Hi, everybody: I made a view - works as creating a new comment for a specific article, a example URL is "http://localhost:3000/comments/new/2": here, comments is the controller, new is the action, 2 is the id of the specific article, which needs to be passed to next action "create", so that this comment will be attached and displayed under 2nd article. However, I didnt figure out how I can pass the id to next action named "create" in this controller, seems like only the "comments" is the only parameter when I click the "create" button... what can I do? the new view as follow: =============================== <h1>New comment</h1> <%= error_messages_for :comment %> <% form_for(@comment) do |f| %> <p> <b>Desc</b><br /> <%= f.text_area :desc %> </p> <p> <%= f.submit "Create" %> </p> <% end %> ================================= Thanks dudes! Myst --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Shortly I wanna deliver not only the "comments" but also the "id" as params to next action. On 1月10日, 下午9时22分, myst_tt <tdxia...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, everybody: > I made a view - works as creating a new comment for a specific > article, a example URL is "http://localhost:3000/comments/new/2": > here, comments is the controller, new is the action, 2 is the id of > the specific article, which needs to be passed to next action > "create", so that this comment will be attached and displayed under > 2nd article. However, I didnt figure out how I can pass the id to next > action named "create" in this controller, seems like only the > "comments" is the only parameter when I click the "create" button... > what can I do? > > the new view as follow: > ===============================> > <h1>New comment</h1> > > <%= error_messages_for :comment %> > > <% form_for(@comment) do |f| %> > <p> > <b>Desc</b><br /> > <%= f.text_area :desc %> > </p> > > <p> > <%= f.submit "Create" %> > </p> > <% end %> > =================================> > Thanks dudes! > Myst--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
myst_tt wrote:> Shortly I wanna deliver not only the "comments" but also the "id" as > params to next action.Pass the id to the URL that the form posts to. <% form_for @comment, :url => {:id => @comment} do |f| %> -- 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 -~----------~----~----~----~------~----~------~--~---
Why not change the URL completely? Have it as /posts/2/comments/new? That way form_for(@comment) *should* generate the proper URL for it. On Jan 11, 2008 6:37 AM, Jeremy Weiskotten <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > myst_tt wrote: > > Shortly I wanna deliver not only the "comments" but also the "id" as > > params to next action. > > Pass the id to the URL that the form posts to. > > <% form_for @comment, :url => {:id => @comment} do |f| %> > -- > Posted via http://www.ruby-forum.com/. > > > >-- 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 -~----------~----~----~----~------~----~------~--~---
good idea, RESTful... now I got to figure out how to do the nested URL in route.rb, but anyway, thanks for your comments! Br, Myst On 1月10日, 下午10时41分, "Ryan Bigg" <radarliste...@gmail.com> wrote:> Why not change the URL completely? Have it as /posts/2/comments/new? That > way form_for(@comment) *should* generate the proper URL for it. > > On Jan 11, 2008 6:37 AM, Jeremy Weiskotten <rails-mailing-l...@andreas-s.net> > wrote: > > > > > myst_tt wrote: > > > Shortly I wanna deliver not only the "comments" but also the "id" as > > > params to next action. > > > Pass the id to the URL that the form posts to. > > > <% form_for @comment, :url => {:id => @comment} do |f| %> > > -- > > Posted viahttp://www.ruby-forum.com/. > > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
map.resources :posts, :has_many => :comments or if you're not using Rails 2.0 map.resources :posts do |post| post.resources :comments end On Jan 11, 2008 7:24 AM, myst_tt <tdxiaoxi@gmail.com> wrote:> > good idea, RESTful... now I got to figure out how to do the nested > URL in route.rb, but anyway, thanks for your comments! > > Br, > Myst > > On 1月10日, 下午10时41分, "Ryan Bigg" <radarliste...@gmail.com> wrote: > > Why not change the URL completely? Have it as /posts/2/comments/new? > That > > way form_for(@comment) *should* generate the proper URL for it. > > > > On Jan 11, 2008 6:37 AM, Jeremy Weiskotten < > rails-mailing-l...@andreas-s.net> > > wrote: > > > > > > > > > myst_tt wrote: > > > > Shortly I wanna deliver not only the "comments" but also the "id" as > > > > params to next action. > > > > > Pass the id to the URL that the form posts to. > > > > > <% form_for @comment, :url => {:id => @comment} do |f| %> > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > > -- > > Ryan Bigghttp://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > >-- 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---
Really big hand! On 1月10日, 下午10时54分, myst_tt <tdxia...-Re5JQEeQqe8@public.gmane.orgm> wrote:> good idea, RESTful... now I got to figure out how to do the nested > URL in route.rb, but anyway, thanks for your comments! > > Br, > Myst > > On 1月10日, 下午10时41分, "Ryan Bigg" <radarliste...@gmail.com> wrote: > > > Why not change the URL completely? Have it as /posts/2/comments/new? That > > way form_for(@comment) *should* generate the proper URL for it. > > > On Jan 11, 2008 6:37 AM, Jeremy Weiskotten <rails-mailing-l...@andreas-s.net> > > wrote: > > > > myst_tt wrote: > > > > Shortly I wanna deliver not only the "comments" but also the "id" as > > > > params to next action. > > > > Pass the id to the URL that the form posts to. > > > > <% form_for @comment, :url => {:id => @comment} do |f| %> > > > -- > > > Posted viahttp://www.ruby-forum.com/. > > > -- > > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---