Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

Enterprise intelligence with prediction markets

Find out what your team, colleagues and partners really know about the future — and leverage their knowledge to improve business decisions.

I'm the founder of Planypus, the place to share your plans!

Archives

Contact

Reach me at yan at pritzker.ws

Rails form multiple submits to multiple controller actions

Posted 11 September 2006 @ 4pm | Tagged thoughts


Submit to HN

Say you have a form that can have multiple actions. For example, you have a list of emails and you need to do the following: confirm, resend confirmation, make primary (think Paypal). I’ve created a simple helper that just sets the form’s action on the button’s click event so the form can get submitted to different actions on the controller:

# lang ruby
def submit_tag_to_action(value, action, options={})
  submit_tag(value, options.merge!(:onclick => "this.form.action='#{action}'"))
end

### usage:
submit_tag_to_action "myButton", "myAction"

3 Comments

Posted by
Karen
20 September 2006 @ 8am

I cannot get this to work, as it won’t pass an extra :id param that I need.

Original form was something like (preview not working because don’t pass form parameters):
‘update’, :id => @article %>
‘edit_form’ %>

‘preview’, :id => @article %>
‘list’ %>

Tried the following, but save and preview won’t work:

‘edit_form’ %>
@article %>
@article %>
‘list’ %>

How do I add an extra param?


Posted by
Yan
20 September 2006 @ 2pm

Karen can you please email me at yan@pritzker.ws, I think wordpress killed the formatting of your comments. Or try to surround them by ‘pre’ tags.


Posted by
Nico
31 October 2006 @ 4pm

Thank you it works perfect


Leave a Comment