Hi, I am somewhat new to rails, and I have a question about form_tag: I have the following : <%form_tag "some_action" do%> ... and I have a route for "posts/:id/some_action" When I run this, I notice that (what seems miraculously), the app fills in the id while calling this route like: posts/12/some_action and even more surprisingly 12 is the id of the current post in my context. My question is: without my specifying the id anywhere, how could rails know the id - is it reading my mind? Or maybe I am missing how form_tag works (I assumed that it requires the id to be passed in explicitly to work). Thanks Anand -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jul 25, 11:01 pm, Anand Ramanathan <rcan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I run this, I notice that (what seems miraculously), the app fills in > the id while calling this route like: > > posts/12/some_action > > and even more surprisingly 12 is the id of the current post in my context. > > My question is: without my specifying the id anywhere, how could rails know > the id - is it reading my mind? Or maybe I am missing how form_tag works (I > assumed that it requires the id to be passed in explicitly to work).Sounds like you''ve created a form whose action is a relative path - no rails magic here, just html. Fred -- 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.
Ah, ok - got it. Thanks! On Sun, Jul 25, 2010 at 3:05 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Jul 25, 11:01 pm, Anand Ramanathan <rcan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > When I run this, I notice that (what seems miraculously), the app fills > in > > the id while calling this route like: > > > > posts/12/some_action > > > > and even more surprisingly 12 is the id of the current post in my > context. > > > > My question is: without my specifying the id anywhere, how could rails > know > > the id - is it reading my mind? Or maybe I am missing how form_tag works > (I > > assumed that it requires the id to be passed in explicitly to work). > > Sounds like you''ve created a form whose action is a relative path - no > rails magic here, just html. > > Fred > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.