Created
December 3, 2014 08:19
-
-
Save px-amaac/5b1164aa0efe357b57f6 to your computer and use it in GitHub Desktop.
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 TutorialsController < ApplicationController | |
before_action :set_tutorial, only: [ :show ] | |
before_action :correct_user, only: [ :show, :edit, :update, :destroy ] | |
before_action :authenticate_user! | |
... | |
... | |
... | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_tutorial | |
@tutorial = Tutorial.find(params[:id]) | |
end | |
def correct_user | |
@tutorial = current_user.tutorials.find_by(id: params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def tutorial_params | |
params.require(:tutorial).permit(:title, :author, :description, :user_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment