I''ve been using Rails for a while and am fairly comfortable with it, but I keep stumbling when using form_for and form_tag. I''m using RESTful routes and simply want to create a form using form_tag that specifies :method => :put and an onsubmit handler. I''ve tried things like <% form_tag ({:url => password_path(id)}, {:html => {:method => :put, :onsubmit => "return true;"}}) do %> ... <% end %> and <% form_tag (:url => password_path(id), :method => :put, :onsubmit => "return true;"}) do %> ... <% end %> and <% form_tag :url => password_path(id), :method => :put, :onsubmit => "return true;") do %> ... <% end %> and can''t get the method in the form to be set to ''put''. Also, some of these produce some pretty odd form actions... I''m obviously missing something with the form_tag syntax here, but it''s not clear what it is. FYI, I''m using Rails 2.0.2. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This one gets me almost there: <% form_tag (password_path(id), {:method => :put, :onsubmit => "return true;"}) do %> ... <% end %> but the form method is still ''post'' On Jan 10, 4:18 pm, bigbanger <bigbanger...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve been using Rails for a while and am fairly comfortable with it, > but I keep stumbling when using form_for and form_tag. I''m using > RESTful routes and simply want to create a form using form_tag that > specifies :method => :put and an onsubmit handler. I''ve tried things > like > > <% form_tag ({:url => password_path(id)}, {:html => {:method > => :put, :onsubmit => "return true;"}}) do %> > ... > <% end %> > > and > > <% form_tag (:url => password_path(id), :method => :put, :onsubmit => > "return true;"}) do %> > ... > <% end %> > > and > > <% form_tag :url => password_path(id), :method => :put, :onsubmit => > "return true;") do %> > ... > <% end %> > > and can''t get the method in the form to be set to ''put''. Also, some > of these produce some pretty odd form actions... > > I''m obviously missing something with the form_tag syntax here, but > it''s not clear what it is. FYI, I''m using Rails 2.0.2.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Does this work? (I prefer form_for over form_tag...) form_for(:user, :url => password_path(@user), :html => {:method => :put, :onsubmit => ''return false;''}) do |f| ... 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 -~----------~----~----~----~------~----~------~--~---
When using PUT in forms the method will always be post in the forms. The form is not what sends that method, it''s rather the javascript that''s triggered when you submit that form. Don''t put spaces before your parenthesis either, do form_tag() instead of form_tag () On Jan 11, 2008 10:53 AM, bigbanger <bigbanger10s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > This one gets me almost there: > > <% form_tag (password_path(id), {:method => :put, :onsubmit => "return > true;"}) do %> > ... > <% end %> > > but the form method is still ''post'' > > On Jan 10, 4:18 pm, bigbanger <bigbanger...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I''ve been using Rails for a while and am fairly comfortable with it, > > but I keep stumbling when using form_for and form_tag. I''m using > > RESTful routes and simply want to create a form using form_tag that > > specifies :method => :put and an onsubmit handler. I''ve tried things > > like > > > > <% form_tag ({:url => password_path(id)}, {:html => {:method > > => :put, :onsubmit => "return true;"}}) do %> > > ... > > <% end %> > > > > and > > > > <% form_tag (:url => password_path(id), :method => :put, :onsubmit => > > "return true;"}) do %> > > ... > > <% end %> > > > > and > > > > <% form_tag :url => password_path(id), :method => :put, :onsubmit => > > "return true;") do %> > > ... > > <% end %> > > > > and can''t get the method in the form to be set to ''put''. Also, some > > of these produce some pretty odd form actions... > > > > I''m obviously missing something with the form_tag syntax here, but > > it''s not clear what it is. FYI, I''m using Rails 2.0.2. > > >-- 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 -~----------~----~----~----~------~----~------~--~---
On Jan 10, 5:17 pm, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When using PUT in forms the method will always be post in the forms. The > form is not what sends that method, it''s rather the javascript that''s > triggered when you submit that form. Don''t put spaces before your > parenthesis either, do form_tag() instead of form_tag ()Ryan, thanks. I discovered that shortly after I posted and I deleted my post, but I guess it hung around long enough for it to be viewed by a few people. Thanks again for responding. --~--~---------~--~----~------------~-------~--~----~ 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 Jan 12, 2008, at 12:32 AM, bigbanger wrote:> Ryan, thanks. I discovered that shortly after I posted and I deleted > my post, but I guess it hung around long enough for it to be viewed by > a few people. Thanks again for responding.Actually, if you submitted it via ruby-forum or google-groups, your post gets submitted to a mailing list, so even if you deleted it right after posting, everyone subscribed to list would have received it. Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ 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 Jan 12, 5:14 am, Phillip Koebbe <phillipkoe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Actually, if you submitted it via ruby-forum or google-groups, your > post gets submitted to a mailing list, so even if you deleted it > right after posting, everyone subscribed to list would have received it.Ahh, that explains it. Thanks Phillip. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Weiskotten wrote:> Does this work? (I prefer form_for over form_tag...) > > form_for(:user, :url => password_path(@user), :html => {:method => :put, > :onsubmit => ''return false;''}) do |f| > ... > endJeremy, Curious about your preference, because I was trying to use form_for (it''s designed for forms related to models) but kept running into trouble using a collection_select to get a pop-up supplying values from a has_one table. Suppose in your example of "user" you wanted to select role from an ancillary table of roles {"novice", "admin", "super admin"} Would you use f.collection_select? I''ve been trying to get that to work, and always have to drop back to form_tag and specify my model and collection implicitly. Cheers, Jim -- 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 -~----------~----~----~----~------~----~------~--~---