Created
February 27, 2012 13:13
-
-
Save mati0090/1923694 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ send_for_approval: "sent for approval", | |
deactivate: "deactivated", | |
reactivate: "reactivated", | |
}.each do |status, desc| | |
define_method status do | |
if @offer.send(status) | |
redirect_to @offer, :notice => "Offer was #{desc}." | |
else | |
render :action => "edit" | |
end | |
end | |
end |
staszek
commented
Feb 27, 2012
def send_for_approval
change_state(@offer.send_for_approval, 'sent for approval')
end
def deactivate
change_state(@offer.deactivate, 'deactivated')
end
def reactivate
change_state(@offer.reactivate, 'reactivated')
end
private
def change_state(result, snippet)
if result
redirect_to @offer, :notice => "Offer was #{snippet}"
else
render :action => "edit"
end
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment