Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (39 sloc) 1.04 KB
class TasksController < ApplicationController
def index
@todo = Task.where(:done => false)
@task = Task.new
@lists = List.all
@list = List.new
respond_to do |format|
format.html
end
end
def create
@list = List.find(params[:list_id])
@task = @list.tasks.new(params[:task])
if @task.save
flash[:notice] = "Your task was created."
else
flash[:alert] = "There was an error creating your task."
end
redirect_to(list_tasks_url(@list))
end
def update
@list = List.find(params[:list_id])
@task = @list.tasks.find(params[:id])
respond_to do |format|
if @task.update_attributes(params[:task])
format.html { redirect_to( list_tasks_url(@list), :notice => 'Task was successfully updated.') }
else
format.html { render :action => "edit" }
end
end
end
def destroy
@task = Task.find(params[:id])
@task.destroy
respond_to do |format|
format.html { redirect_to(list_tasks_url(@list)) }
end
end
end
Something went wrong with that request. Please try again.