Class: TodosController

Inherits:
Reloj::ControllerBase show all
Defined in:
lib/reloj/skeletons/sample_app/app/controllers/todos_controller.rb

Instance Attribute Summary

Attributes inherited from Reloj::ControllerBase

#params, #req, #res

Instance Method Summary collapse

Methods inherited from Reloj::ControllerBase

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

Methods included from RouteHelper

included

Constructor Details

This class inherits a constructor from Reloj::ControllerBase

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
# File 'lib/reloj/skeletons/sample_app/app/controllers/todos_controller.rb', line 13

def create
  @todo = Todo.new(params[:todo])
  if @todo.title == "" || @todo.save
    redirect_to "/"
  else
    render :new
  end
end

#destroyObject



22
23
24
25
26
# File 'lib/reloj/skeletons/sample_app/app/controllers/todos_controller.rb', line 22

def destroy
  @todo = Todo.find(params[:id])
  @todo.destroy
  render_content("{}", "application/json")
end

#indexObject



3
4
5
6
# File 'lib/reloj/skeletons/sample_app/app/controllers/todos_controller.rb', line 3

def index
  @todos = Todo.all
  render :index
end

#newObject



8
9
10
11
# File 'lib/reloj/skeletons/sample_app/app/controllers/todos_controller.rb', line 8

def new
  @todo = Todo.new
  render :new
end