Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Is this unless block really needed? n.attribute?

View ThugNotes PUT block Edit
1 2 3 4 5 6 7 8 9 10 11 12 13
# 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
View ThugNotes PUT block Edit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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
Something went wrong with that request. Please try again.