Class: Admin::AuthorsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lines/admin/authors_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

Create a new author from params



30
31
32
33
34
35
36
37
38
# File 'app/controllers/lines/admin/authors_controller.rb', line 30

def create
  @author = Author.new(author_params)

  if @author.save
    redirect_to admin_author_path @author, notice: 'Author was successfully created.'
  else
    render action: "new"
  end
end

#destroyObject

Delete an author



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

def destroy
  @author = Author.find(params[:id])
  if @author.destroy
    redirect_to admin_authors_url
  else
    @authors = Author.all
    render "index" 
  end
end

#editObject

Edit an existing author



25
26
27
# File 'app/controllers/lines/admin/authors_controller.rb', line 25

def edit
  @author = Author.find(params[:id])
end

#indexObject

Listes all authroes



10
11
12
# File 'app/controllers/lines/admin/authors_controller.rb', line 10

def index
  @authors = Author.all
end

#newObject

New author



20
21
22
# File 'app/controllers/lines/admin/authors_controller.rb', line 20

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

#showObject

Shows an author



15
16
17
# File 'app/controllers/lines/admin/authors_controller.rb', line 15

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

#updateObject

Update an existing author from params



41
42
43
44
45
46
47
48
49
# File 'app/controllers/lines/admin/authors_controller.rb', line 41

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

  if @author.update_attributes(params[:author])
    redirect_to admin_author_path @author, notice: 'Author was successfully updated.'
  else
    render action: "edit"
  end
end