From 5ff9457ee3d2f1c636da8d13c47c608543d2e5f7 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 29 Jun 2017 14:53:15 -0400 Subject: Worked on style of blog posts --- app/controllers/entries_controller.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 89d06c0..366de53 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -1,7 +1,26 @@ class EntriesController < ApplicationController + before_action :authenticate_user!, only: [:edit, :update] def show - @entry = Entry.where(directory: params[:directory], slug: params[:slug]).first + @entry = Entry.where(slug: params[:slug]).first end + def edit + @entry = Entry.where(slug: params[:slug]).first + end + + def update + @entry = Entry.where(slug: params[:slug]).first + + if @entry.update_attributes(entry_params) + flash.notice = "" + end + end + + private + + def entry_params + params.require(:blog).permit(:title, :body, :slug) + end + end -- cgit 1.4.1