Class: ShelvesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/shelves_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


27
28
29
30
31
32
# File 'app/controllers/shelves_controller.rb', line 27

def create
  @shelf = current_user.shelves.new(shelf_params)
  authorize @shelf
  @shelf.save
  respond_with(@shelf)
end

#destroyObject


39
40
41
42
# File 'app/controllers/shelves_controller.rb', line 39

def destroy
  @shelf.destroy
  respond_with(@shelf)
end

#editObject


24
25
# File 'app/controllers/shelves_controller.rb', line 24

def edit
end

#indexObject


7
8
9
10
11
# File 'app/controllers/shelves_controller.rb', line 7

def index
  authorize :shelf, :index? unless user_signed_in?
  @shelves = policy_scope(Shelf) # current_user.shelves
  respond_with(@shelves)
end

#newObject


18
19
20
21
22
# File 'app/controllers/shelves_controller.rb', line 18

def new
  @shelf = current_user.shelves.new
  authorize @shelf
  respond_with(@shelf)
end

#showObject


13
14
15
16
# File 'app/controllers/shelves_controller.rb', line 13

def show
  @books = @shelf.books.page(params[:page])
  respond_with(@shelf)
end

#updateObject


34
35
36
37
# File 'app/controllers/shelves_controller.rb', line 34

def update
  @shelf.update(shelf_params)
  respond_with(@shelf)
end