From 90c3361f882d10043affe4099a912f7596305599 Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Sat, 30 Aug 2014 17:37:08 +0300 Subject: [PATCH] Lecture editing --- app/controllers/lectures_controller.rb | 7 ++++++- app/views/lectures/edit.html.slim | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/lectures_controller.rb b/app/controllers/lectures_controller.rb index af3ade6..1397267 100644 --- a/app/controllers/lectures_controller.rb +++ b/app/controllers/lectures_controller.rb @@ -1,6 +1,6 @@ class LecturesController < ApplicationController before_filter :authenticate_user! - before_action :assign_lecture, only: [:show] + before_action :assign_lecture, only: [:show, :edit, :update] def new @lecture = Lecture.new @@ -20,6 +20,11 @@ class LecturesController < ApplicationController end def update + if @lecture.update lecture_params + redirect_to @lecture + else + render :edit, status: :unprocessable_entity + end end def show diff --git a/app/views/lectures/edit.html.slim b/app/views/lectures/edit.html.slim index 8963bd0..404990a 100644 --- a/app/views/lectures/edit.html.slim +++ b/app/views/lectures/edit.html.slim @@ -1,2 +1,2 @@ -h1 Lectures#edit -p Find me in app/views/lectures/edit.html.slim +h1.entry-title Редакция на лекция += render 'form'