This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit cd653140c3f4a395086607f62dc7d1df6d7a4b26
tree e88a2f1403bbac77dae650c95801317fa1c7b221
parent 1c912997bdff6ee5a93e666bc5cd25da47e17fb4
tree e88a2f1403bbac77dae650c95801317fa1c7b221
parent 1c912997bdff6ee5a93e666bc5cd25da47e17fb4
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Mon Jul 16 02:45:07 -0700 2007 | |
| |
README | Mon Jul 16 02:45:07 -0700 2007 | |
| |
Rakefile | Mon Jul 16 02:45:07 -0700 2007 | |
| |
init.rb | Mon Jul 16 02:45:07 -0700 2007 | |
| |
lib/ | Thu Aug 09 06:59:02 -0700 2007 | |
| |
tasks/ | Mon Jul 16 02:45:07 -0700 2007 | |
| |
test/ | Mon Jul 16 02:45:07 -0700 2007 |
README
= WithAction
A respond_to style helper for doing different actions based on which request parameters are passed. Specifically, it is
helpful if you want to use multiple form buttons on a page, such as "Save", "Save and Continue Editing", and "Cancel".
with_action executes different blocks based on what the presence of request parameters.
def create
with_action do |a|
a.cancel { redirect_to articles_path }
a.any do
@article = Article.new(params[:article])
if @article.save
a.save { redirect_to article_path(@article) }
a.edit { redirect_to article_path(@article) }
a.approve do
@article.approve!
redirect_to article_path(@article)
end
else
render :action => 'new'
end
end
end
end
A block is invoked if a parameter with the same name exists and is not blank. Here is an example of a form to submit to
this action:
<%= submit_tag 'Save', :name => 'save' %>
<%= submit_tag 'Save & Continue Editing', :name => 'edit' %>
<%= submit_tag 'Save & Approve', :name => 'approve' %>
<%= submit_tag 'Cancel', :name => 'cancel' %>
If an @any@ block is present and no parameter that matches one of the other blocks, it is called by default, otherwise
the first block will be called. The @any@ block is the only one that can have nesting and be called multiple times.
(c) Copyright 2007 Brandon Keepers (brandon@opensoul.org)







