Class: Fuel::Admin::PostsController

Inherits:
AdminController show all
Defined in:
app/controllers/fuel/admin/posts_controller.rb

Instance Method Summary collapse

Methods inherited from FuelController

#not_found, #s3_bucket

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/fuel/admin/posts_controller.rb', line 16

def create
  @params_hash = Rails.version[0].to_i < 4 ? params[:fuel_post] : post_params
  update_published_at
  @post = Fuel::Post.new(@params_hash)
  set_message

  if @post.save
    redirect_to fuel.admin_posts_path, notice: "Your blog post was successfully #{@message}."
  else
    render action: "new"
  end
end

#destroyObject



46
47
48
49
# File 'app/controllers/fuel/admin/posts_controller.rb', line 46

def destroy
  @post.destroy
  redirect_to fuel.admin_posts_path, notice: "Post was successfully deleted"
end

#editObject



29
30
31
# File 'app/controllers/fuel/admin/posts_controller.rb', line 29

def edit

end

#indexObject



9
10
# File 'app/controllers/fuel/admin/posts_controller.rb', line 9

def index
end

#newObject



12
13
14
# File 'app/controllers/fuel/admin/posts_controller.rb', line 12

def new
  @post = Fuel::Post.new
end

#previewObject



51
52
53
54
55
56
57
58
59
# File 'app/controllers/fuel/admin/posts_controller.rb', line 51

def preview
  @content = params[:fuel_post][:content]
  content = Fuel::Post.new.to_html(@content)
  html = render_to_string partial: "fuel/admin/posts/content", locals: { content: content }

  respond_to do |format|
    format.json { render json: { html: html } }
  end
end

#showObject



61
62
# File 'app/controllers/fuel/admin/posts_controller.rb', line 61

def show
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/fuel/admin/posts_controller.rb', line 33

def update
  @params_hash = Rails.version[0].to_i < 4 ? params[:fuel_post] : post_params
  update_published_at
  @post.attributes = @params_hash
  set_message

  if @post.save
    redirect_to fuel.edit_admin_post_path(@post), notice: "Post was updated and #{@message}"
  else
    render "edit"
  end
end