Created
June 29, 2012 18:38
-
-
Save malachaifrazier/3019890 to your computer and use it in GitHub Desktop.
Is this unless block really needed? n.attribute?
This file contains hidden or 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
# Are the 'n.attribute' and 'unless' blocks really needed here? | |
put '/:id' do | |
n = Note.get params[:id] | |
n.content = params[:content] | |
n.complete = params[:complete] ? 1 : 0 | |
n.updated_at = Time.now | |
if n.save | |
redirect '/', :notice => "Note updated thuggishly." | |
else | |
redirect '/', :error => 'Update failed, son.' | |
end | |
end |
This file contains hidden or 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
put '/:id' do | |
n = Note.get params[:id] | |
unless n | |
redirect '/', :error => "No Note to be found, son." | |
end | |
n.attributes = { | |
:content => params[:content], | |
:complete => params[:complete] ? 1 : 0, | |
:updated_at => Time.now #.strftime("%m/%d/%Y %I:%M%p") | |
} | |
if n.save | |
redirect '/', :notice => "Note updated thuggishly." | |
else | |
redirect '/', :error => 'Update failed, son.' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment