Class: CatsController

Inherits:
ControllerBase show all
Defined in:
app/controllers/cats_controller.rb

Instance Attribute Summary

Attributes inherited from ControllerBase

#params, #req, #res

Instance Method Summary collapse

Methods inherited from ControllerBase

#already_built_response?, #controller_name, #initialize, #invoke_action, #redirect_to, #render, #render_content, #session

Constructor Details

This class inherits a constructor from ControllerBase

Instance Method Details

#createObject



20
21
22
23
24
25
# File 'app/controllers/cats_controller.rb', line 20

def create
  @cat = Cat.new
  @cat.name = params['cat']['name']
  @cat.save
  render :show
end

#indexObject



6
7
8
9
# File 'app/controllers/cats_controller.rb', line 6

def index
  @cats = Cat.all
  render :index
end

#newObject



16
17
18
# File 'app/controllers/cats_controller.rb', line 16

def new
  render :new
end

#showObject



11
12
13
14
# File 'app/controllers/cats_controller.rb', line 11

def show
  @cat = Cat.find(Integer(params['cat_id']))
  render :show
end