Created
August 25, 2016 00:53
-
-
Save bootcoder/c568f25682da2f244bd55e7797738f33 to your computer and use it in GitHub Desktop.
baseline_RR_pattern
This file contains 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
# Cat INDEX | |
get '/categories' do | |
@categories = Category.all | |
erb :'categories/index' | |
end | |
# Cat NEW | |
get '/categories/new' do | |
@category = Category.new | |
erb :'categories/new' | |
end | |
# Cat CREATE | |
post '/categories' do | |
@category = Category.new(params[:category]) | |
if @category.save | |
redirect '/categories' | |
else | |
@errors = @category.errors.full_messages | |
erb :'categories/new' | |
end | |
end | |
# Cat SHOW | |
get '/categories/:id' do | |
@category = Category.find(params[:id]) | |
erb :'categories/show' | |
end | |
# Cat EDIT | |
get '/categories/:id/edit' do | |
@category = Category.find(params[:id]) | |
erb :'categories/edit' | |
end | |
# Cat UPDATE | |
put '/categories/:id' do | |
@category = Category.find(params[:id]) | |
@category.update(params[:category]) | |
redirect "/categories/#{@category.id}" | |
end | |
# Cat DESTROY | |
delete '/categories/:id' do | |
@category = Category.find(params[:id]) | |
@category.destroy | |
redirect "/categories" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment