Class: TodosController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/app/controllers/todos_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
# File 'lib/app/controllers/todos_controller.rb', line 21

def create
  @todo = @calendar.todos.create(params[:todo])
  flash[:notice] = "Todo successfully created" if @todo.save
  respond_with(@calendar, @todo)
end

#destroyObject



33
34
35
36
37
38
39
40
41
# File 'lib/app/controllers/todos_controller.rb', line 33

def destroy
  @todo = @calendar.todos.find(params[:id])
  @todo.destroy

  respond_to do |format|
    format.html { redirect_to(calendars_todos_url(@calendar, @todo)) }
    format.xml  { head :ok }
  end
end

#editObject



17
18
19
# File 'lib/app/controllers/todos_controller.rb', line 17

def edit
  respond_with(@calendar, (@todo = @calendar.todos.find(params[:id])))
end

#indexObject



5
6
7
# File 'lib/app/controllers/todos_controller.rb', line 5

def index
  respond_with(@calendar, (@todos = @calendar.todos.all))
end

#newObject



13
14
15
# File 'lib/app/controllers/todos_controller.rb', line 13

def new
  respond_with(@calendar, (@todo = @calendar.todos.new))
end

#showObject



9
10
11
# File 'lib/app/controllers/todos_controller.rb', line 9

def show
  respond_with(@calendar, (@todo = @calendar.todos.find(params[:id])))
end

#updateObject



27
28
29
30
31
# File 'lib/app/controllers/todos_controller.rb', line 27

def update
  @todo = @calendar.todos.find(params[:id])
  @todo.update_attributes(params[:calendar])
  respond_with(@calendar, @todo)
end