Skip to content

Instantly share code, notes, and snippets.

@armandofox
Created February 16, 2016 01:12
Show Gist options
  • Save armandofox/b96462d7773a1a96dbf4 to your computer and use it in GitHub Desktop.
Save armandofox/b96462d7773a1a96dbf4 to your computer and use it in GitHub Desktop.
moviegoer_owns_review.rb
class ReviewsController < ApplicationController
before_filter :moviegoer_owns_review, :only => [:edit, :update]
def moviegoer_owns_review
unless Review.find_by_id(params[:id]).try(:moviegoer) == @current_user
flash[:warning] = 'You can only edit your own reviews.'
redirect_to movies_path
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment