Created
July 11, 2016 15:20
-
-
Save jetrubyshared/9960c2280a14ff2acf0cdf9e4bf3fade to your computer and use it in GitHub Desktop.
This file contains 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
############### | |
## WRONG ## | |
############### | |
class Users::CoursesController | |
def edit | |
@course = Course.find(params[:id]) | |
end | |
end | |
class Users::LessonsController | |
def new | |
@lesson = Lesson.new(lesson_params) | |
end | |
end | |
############### | |
## RIGHT ## | |
############### | |
class Users::CoursesController | |
def edit | |
@course = current_user.courses.find(params[:id]) | |
end | |
end | |
class Users::LessonsController | |
def new | |
course = current_user.courses.find(params[:course_id]) | |
@lesson = course.lessons.build(lesson_params) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment