Created
June 6, 2017 03:34
-
-
Save sushant12/6cd3d66981b0902dcb9845f03a1f125b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TaskController < ApplicationController | |
get '/' do | |
@tasks = Task.all | |
erb :index | |
end | |
post '/save' do | |
Task.create(name: params[:task]) | |
redirect '/' | |
end | |
get '/delete/:id' do | |
task = Task.find_by(id: params[:id]) | |
task.destroy | |
redirect '/' | |
end | |
get '/edit/:id' do | |
@task = Task.find_by(id: params[:id]) | |
erb :edit | |
end | |
post '/update/:id' do | |
task = Task.find_by(id: params[:id]) | |
task.name = params[:task] | |
task.finished = params[:finished] | |
task.save | |
redirect '/' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment