Skip to content

Instantly share code, notes, and snippets.

@wfarr
Created December 17, 2009 22:22
Show Gist options
  • Select an option

  • Save wfarr/259079 to your computer and use it in GitHub Desktop.

Select an option

Save wfarr/259079 to your computer and use it in GitHub Desktop.
get '/posts/:id/edit' do
@post = Post.find(params[:id])
haml :"posts/edit"
end
put '/posts/:id' do
@post = Post.find(params[:id])
@post.update_attributes(params)
cleanup @post
redirect "/posts/#{@post.id}"
end
%form{:action => "/posts/#{@post.id}", :method => 'post'}
%input{:type => 'hidden', :name => '_method', :value => 'put'}
%p
%label{:for => 'title'}Title:
%input{:name => 'title', :id => 'title', :value => @post.title}
%p
%label{:for => 'tags_list'}Tags:
%input{:name => 'tags_list', :id => 'tags_list', :value => @post.tags_list}
%p
%label{:for => 'body'}Body:
%br/
= find_and_preserve do
%textarea{:name => 'body', :id => 'body', :rows => '12', :cols => '40'}= @post.body
%p
%input{:type => 'submit'}
%a{:href => "/posts/#{@post.id}"} Back
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment