Class: Spina::Admin::Conferences::Blog::PostsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/spina/admin/conferences/blog/posts_controller.rb

Overview

Spina::Admin::Conferences::Blog::PostsController

Instance Method Summary collapse

Instance Method Details

#createObject



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 42

def create
  @post = Spina::Admin::Conferences::Blog::Post.new post_params
  if @post.save
    redirect_to spina.edit_admin_conferences_blog_post_url(@post.id),
                notice: t('spina.blog.posts.saved')
  else
    add_breadcrumb I18n.t('spina.blog.posts.new')
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



69
70
71
72
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 69

def destroy
  @post.destroy
  redirect_to spina.admin_conferences_blog_posts_path
end

#draftObject



26
27
28
29
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 26

def draft
  @posts = Spina::Admin::Conferences::Blog::Post.draft.order(created_at: :desc)
  render :index
end

#editObject



53
54
55
56
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 53

def edit
  add_breadcrumb @post.title
  render layout: 'spina/admin/admin'
end

#futureObject



31
32
33
34
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 31

def future
  @posts = Spina::Admin::Conferences::Blog::Post.future.order(created_at: :desc)
  render :index
end

#indexObject



17
18
19
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 17

def index
  @posts = Spina::Admin::Conferences::Blog::Post.order(created_at: :desc)
end

#liveObject



21
22
23
24
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 21

def live
  @posts = Spina::Admin::Conferences::Blog::Post.live.order(created_at: :desc)
  render :index
end

#newObject



36
37
38
39
40
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 36

def new
  @post = Spina::Admin::Conferences::Blog::Post.new
  add_breadcrumb I18n.t('spina.blog.posts.new')
  render layout: 'spina/admin/admin'
end

#updateObject



58
59
60
61
62
63
64
65
66
67
# File 'app/controllers/spina/admin/conferences/blog/posts_controller.rb', line 58

def update
  if @post.update(post_params)
    add_breadcrumb @post.title
    redirect_to spina.edit_admin_conferences_blog_post_url(
      @post.id, params: { locale: @locale }
    ), notice: t('spina.blog.posts.saved')
  else
    render :edit, status: :unprocessable_entity
  end
end