Class: Fuel::Admin::AuthorsController

Inherits:
AdminController show all
Defined in:
app/controllers/fuel/admin/authors_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
# File 'app/controllers/fuel/admin/authors_controller.rb', line 16

def create
  @params_hash = Rails.version[0].to_i < 4 ? params[:fuel_author] : author_params
  set_start_date
  @author = Fuel::Author.new(@params_hash)

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

#destroyObject



44
45
46
47
48
49
50
51
# File 'app/controllers/fuel/admin/authors_controller.rb', line 44

def destroy
  @author.posts.each do |post|
    post.author_id = nil
    post.save
  end
  @author.destroy
  redirect_to fuel.admin_authors_path, notice: "Author was successfully deleted"
end

#editObject



28
29
30
# File 'app/controllers/fuel/admin/authors_controller.rb', line 28

def edit

end

#indexObject



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

def index
end

#newObject



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

def new
  @author = Fuel::Author.new
end

#showObject



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

def show
  @author = Fuel::Author.find(params[:id])

  respond_to do |format|
    format.json { render json: @author }
  end
end

#updateObject



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

def update
  @params_hash = Rails.version[0].to_i < 4 ? params[:fuel_author] : author_params
  set_start_date
  @author.attributes = @params_hash

  if @author.save
    redirect_to fuel.edit_admin_author_path(@author), notice: "Author was updated and #{@message}"
  else
    render action: "edit"
  end
end