Class: Hitchens::Admin::PostsController

Inherits:
BaseController show all
Defined in:
app/controllers/hitchens/admin/posts_controller.rb

Instance Method Summary collapse

Methods inherited from Hitchens::ApplicationController

#current_ability

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 15

def create
  if @post.save
    flash[:notice] = t 'hitchens.notices.post_created'
    redirect_to admin_posts_path
  else
    render 'new'
  end
end

#destroyObject



37
38
39
40
41
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 37

def destroy
  @post.destroy
  flash[:notice] = t('hitchens.notices.post_deleted')
  redirect_to admin_posts_path
end

#editObject



35
36
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 35

def edit
end

#indexObject



6
7
8
9
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 6

def index
  @posts = @posts.page(params[:page]).per_page(Hitchens.posts_per_page)
  @posts = PostDecorator.decorate @posts
end

#newObject



33
34
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 33

def new
end

#showObject



11
12
13
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 11

def show
  @post = PostDecorator.decorate @post
end

#updateObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/hitchens/admin/posts_controller.rb', line 23

def update
  if @post.update_attributes params[:post]
    flash[:notice] = t 'hitchens.notices.post_updated'
    redirect_to admin_posts_path
  else
    flash[:error] = t 'hitchens.errors.post_not_updated'
    render 'edit'
  end
end