Skip to content

Instantly share code, notes, and snippets.

@buethling
Created March 8, 2011 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save buethling/859774 to your computer and use it in GitHub Desktop.
Save buethling/859774 to your computer and use it in GitHub Desktop.
microposts
class MicropostsController < ApplicationController
before_filter :authenticate, :only => [:create, :destroy]
before_filter :authorized_user, :only => :destroy
.
.
.
def destroy
@micropost.destroy
redirect_back_or root_path
end
private
def authorized_user
@micropost = Micropost.find(params[:id])
redirect_to root_path unless current_user?(@micropost.user)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment