clarion/app/controllers/lectures_controller.rb

43 lines
804 B
Ruby
Raw Normal View History

class LecturesController < ApplicationController
2014-08-30 17:31:29 +03:00
before_filter :authenticate_user!
2014-08-30 17:37:08 +03:00
before_action :assign_lecture, only: [:show, :edit, :update]
2014-08-30 17:31:29 +03:00
def new
@lecture = Lecture.new
end
def create
2014-08-30 17:31:29 +03:00
@lecture = current_user.lectures.build lecture_params
if @lecture.save
redirect_to @lecture
else
render :new, status: :unprocessable_entity
end
end
def edit
end
def update
2014-08-30 17:37:08 +03:00
if @lecture.update lecture_params
redirect_to @lecture
else
render :edit, status: :unprocessable_entity
end
end
def show
end
2014-08-30 17:31:29 +03:00
private
def assign_lecture
@lecture = Lecture.find params[:id]
end
def lecture_params
params.require(:lecture).permit [:title, :subtitle, :length, :language, :abstract, :description, :notes, :track_id]
end
end