Created
February 16, 2016 01:12
-
-
Save armandofox/b96462d7773a1a96dbf4 to your computer and use it in GitHub Desktop.
moviegoer_owns_review.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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