about summary refs log tree commit diff stats
path: root/app/controllers/entries_controller.rb
blob: 366de53d9e9de7b71b7fa6a665cf149c9023fe2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class EntriesController < ApplicationController
  before_action :authenticate_user!, only: [:edit, :update]

  def show
    @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