fixed lessons

This commit is contained in:
Adrian Hinz 2019-09-13 14:41:10 +02:00
parent 4d8a5138f2
commit 43dcc338ad
3 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ module Admin
@lesson = Lesson.new(admin_lesson_params)
@week = @lesson.week
@lesson.course = @week.course
@course = @week.course
params[:week_id] = @week.id
respond_to do |format|
if @lesson.save
@ -89,6 +90,7 @@ module Admin
def set_object
@lesson = Lesson.find(params[:id])
@week = @lesson.week
@course = @week.course
params[:week_id] = @week.id
end

View File

@ -13,7 +13,9 @@ module Admin
# GET /admin/weeks/1
# GET /admin/weeks/1.json
def show; end
def show
@lessons = @week.lessons.page(params[:page])
end
# GET /admin/weeks/new
def new

View File

@ -10,6 +10,7 @@ class Week < ApplicationRecord
# == Relationships ========================================================
belongs_to :course
has_many :lessons
# == Validations ==========================================================
validates :name, presence: true