Mercurial > zeropaste
diff app/controllers/pastes_controller.rb @ 189:b4b7a29b70f6
Initial work for paste deletion.
author | Edho Arief <edho@myconan.net> |
---|---|
date | Sat, 23 Feb 2013 14:01:22 +0900 |
parents | fc234f8cf3d9 |
children | d4682cea8e58 |
line wrap: on
line diff
--- a/app/controllers/pastes_controller.rb Sat Feb 23 13:25:09 2013 +0900 +++ b/app/controllers/pastes_controller.rb Sat Feb 23 14:01:22 2013 +0900 @@ -21,6 +21,7 @@ # GET / def new @paste = Paste.new + @paste.set_paste_key begin @paste.paste = Paste.find(params[:base]).paste rescue @@ -47,6 +48,9 @@ unless params[:paste][:paste].blank? @paste.paste = params[:paste][:paste] end + if params[:paste][:key] + @paste.key = params[:paste][:key] + end end begin @@ -71,4 +75,15 @@ end end + def destroy + @paste = Paste.find(params[:id].to_i) + if @paste.key == params[:paste][:key] + @paste.destroy + flash[:notice] = "Paste ##{params[:id]} deleted" + redirect_to root_path + else + render :action => :show + end + end + end