Class: Lines::Admin::AuthorsController

Inherits:
Lines::ApplicationController 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 = Lines::Author.new(author_params)

  if @author.save
    redirect_to admin_author_path @author
  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 = Lines::Author.find(params[:id])
  if @author.destroy
    redirect_to admin_authors_url
  else
    @authors = Lines::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 = Lines::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 = Lines::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 = Lines::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 = Lines::Author.find(params[:id])

  if @author.update_attributes(author_params)
    redirect_to admin_author_path(@author)
  else
    render action: "edit"
  end
end