rack-allocation_stats 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/demo_rack_apps/Rails_3.2.15/app/controllers/application_controller.rb +3 -0
- data/demo_rack_apps/Rails_3.2.15/app/controllers/projects_controller.rb +83 -0
- data/demo_rack_apps/Rails_3.2.15/app/controllers/tasks_controller.rb +83 -0
- data/demo_rack_apps/Rails_3.2.15/app/helpers/application_helper.rb +2 -0
- data/demo_rack_apps/Rails_3.2.15/app/helpers/projects_helper.rb +2 -0
- data/demo_rack_apps/Rails_3.2.15/app/helpers/tasks_helper.rb +2 -0
- data/demo_rack_apps/Rails_3.2.15/app/models/project.rb +4 -0
- data/demo_rack_apps/Rails_3.2.15/app/models/task.rb +4 -0
- data/demo_rack_apps/Rails_3.2.15/config/application.rb +63 -0
- data/demo_rack_apps/Rails_3.2.15/config/boot.rb +6 -0
- data/demo_rack_apps/Rails_3.2.15/config/environment.rb +5 -0
- data/demo_rack_apps/Rails_3.2.15/config/environments/development.rb +37 -0
- data/demo_rack_apps/Rails_3.2.15/config/environments/production.rb +67 -0
- data/demo_rack_apps/Rails_3.2.15/config/environments/test.rb +37 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/backtrace_silencers.rb +7 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/inflections.rb +15 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/mime_types.rb +5 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/secret_token.rb +7 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/session_store.rb +8 -0
- data/demo_rack_apps/Rails_3.2.15/config/initializers/wrap_parameters.rb +14 -0
- data/demo_rack_apps/Rails_3.2.15/config/routes.rb +64 -0
- data/demo_rack_apps/Rails_3.2.15/db/migrate/20131104031828_create_projects.rb +11 -0
- data/demo_rack_apps/Rails_3.2.15/db/migrate/20131104031829_create_tasks.rb +11 -0
- data/demo_rack_apps/Rails_3.2.15/db/schema.rb +32 -0
- data/demo_rack_apps/Rails_3.2.15/db/seeds.rb +15 -0
- data/demo_rack_apps/Rails_3.2.15/test/functional/projects_controller_test.rb +49 -0
- data/demo_rack_apps/Rails_3.2.15/test/functional/tasks_controller_test.rb +49 -0
- data/demo_rack_apps/Rails_3.2.15/test/performance/browsing_test.rb +12 -0
- data/demo_rack_apps/Rails_3.2.15/test/test_helper.rb +13 -0
- data/demo_rack_apps/Rails_3.2.15/test/unit/helpers/projects_helper_test.rb +4 -0
- data/demo_rack_apps/Rails_3.2.15/test/unit/helpers/tasks_helper_test.rb +4 -0
- data/demo_rack_apps/Rails_3.2.15/test/unit/project_test.rb +7 -0
- data/demo_rack_apps/Rails_3.2.15/test/unit/task_test.rb +7 -0
- data/demo_rack_apps/Rails_4.0.1/app/controllers/application_controller.rb +5 -0
- data/demo_rack_apps/Rails_4.0.1/app/controllers/projects_controller.rb +74 -0
- data/demo_rack_apps/Rails_4.0.1/app/controllers/tasks_controller.rb +74 -0
- data/demo_rack_apps/Rails_4.0.1/app/helpers/application_helper.rb +2 -0
- data/demo_rack_apps/Rails_4.0.1/app/helpers/projects_helper.rb +2 -0
- data/demo_rack_apps/Rails_4.0.1/app/helpers/tasks_helper.rb +2 -0
- data/demo_rack_apps/Rails_4.0.1/app/models/project.rb +3 -0
- data/demo_rack_apps/Rails_4.0.1/app/models/task.rb +3 -0
- data/demo_rack_apps/Rails_4.0.1/config/application.rb +24 -0
- data/demo_rack_apps/Rails_4.0.1/config/boot.rb +4 -0
- data/demo_rack_apps/Rails_4.0.1/config/environment.rb +5 -0
- data/demo_rack_apps/Rails_4.0.1/config/environments/development.rb +29 -0
- data/demo_rack_apps/Rails_4.0.1/config/environments/production.rb +80 -0
- data/demo_rack_apps/Rails_4.0.1/config/environments/test.rb +36 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/backtrace_silencers.rb +7 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/filter_parameter_logging.rb +4 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/inflections.rb +16 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/mime_types.rb +5 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/secret_token.rb +12 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/session_store.rb +3 -0
- data/demo_rack_apps/Rails_4.0.1/config/initializers/wrap_parameters.rb +14 -0
- data/demo_rack_apps/Rails_4.0.1/config/routes.rb +60 -0
- data/demo_rack_apps/Rails_4.0.1/db/migrate/20131102201320_create_projects.rb +11 -0
- data/demo_rack_apps/Rails_4.0.1/db/migrate/20131102201321_create_tasks.rb +11 -0
- data/demo_rack_apps/Rails_4.0.1/db/schema.rb +32 -0
- data/demo_rack_apps/Rails_4.0.1/db/seeds.rb +15 -0
- data/demo_rack_apps/Rails_4.0.1/test/controllers/projects_controller_test.rb +49 -0
- data/demo_rack_apps/Rails_4.0.1/test/controllers/tasks_controller_test.rb +49 -0
- data/demo_rack_apps/Rails_4.0.1/test/helpers/projects_helper_test.rb +4 -0
- data/demo_rack_apps/Rails_4.0.1/test/helpers/tasks_helper_test.rb +4 -0
- data/demo_rack_apps/Rails_4.0.1/test/models/project_test.rb +7 -0
- data/demo_rack_apps/Rails_4.0.1/test/models/task_test.rb +7 -0
- data/demo_rack_apps/Rails_4.0.1/test/test_helper.rb +15 -0
- data/lib/rack/allocation_stats.rb +22 -0
- data/lib/rack/allocation_stats/action.rb +14 -0
- data/lib/rack/allocation_stats/call_app_directly.rb +14 -0
- data/lib/rack/allocation_stats/formatters/base.rb +11 -0
- data/lib/rack/allocation_stats/formatters/html.rb +23 -0
- data/lib/rack/allocation_stats/formatters/json.rb +12 -0
- data/lib/rack/allocation_stats/formatters/text.rb +33 -0
- data/lib/rack/allocation_stats/middleware.rb +62 -0
- data/lib/rack/allocation_stats/tracer.rb +80 -0
- data/spec/factories.rb +53 -0
- data/spec/hello_world_app.rb +21 -0
- data/spec/rack/allocation_stats_spec.rb +216 -0
- data/spec/sinatra_app.rb +10 -0
- data/spec/sinatra_templates_app.rb +85 -0
- data/spec/spec_helper.rb +55 -0
- data/spec/yajl_app.rb +20 -0
- data/spec/yaml_app.rb +20 -0
- metadata +169 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
7
|
+
Rails3215::Application.config.secret_token = '3fb2e586f63c16673c8280fcbe105883573bfb734f639cb6ab32c10593872c79ed828bcae683ac472d608c671153df37233b97bde32da60196adda89fd1bca77'
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
Rails3215::Application.config.session_store :cookie_store, key: '_Rails_3.2.15_session'
|
|
4
|
+
|
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
|
6
|
+
# which shouldn't be used to store highly confidential information
|
|
7
|
+
# (create the session table with "rails generate session_migration")
|
|
8
|
+
# Rails3215::Application.config.session_store :active_record_store
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
#
|
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
|
4
|
+
# is enabled by default.
|
|
5
|
+
|
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
|
8
|
+
wrap_parameters format: [:json]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Disable root element in JSON by default.
|
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
|
13
|
+
self.include_root_in_json = false
|
|
14
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Rails3215::Application.routes.draw do
|
|
2
|
+
resources :tasks
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
resources :projects
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
# The priority is based upon order of creation:
|
|
9
|
+
# first created -> highest priority.
|
|
10
|
+
|
|
11
|
+
# Sample of regular route:
|
|
12
|
+
# match 'products/:id' => 'catalog#view'
|
|
13
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
14
|
+
|
|
15
|
+
# Sample of named route:
|
|
16
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
|
17
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
|
18
|
+
|
|
19
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
20
|
+
# resources :products
|
|
21
|
+
|
|
22
|
+
# Sample resource route with options:
|
|
23
|
+
# resources :products do
|
|
24
|
+
# member do
|
|
25
|
+
# get 'short'
|
|
26
|
+
# post 'toggle'
|
|
27
|
+
# end
|
|
28
|
+
#
|
|
29
|
+
# collection do
|
|
30
|
+
# get 'sold'
|
|
31
|
+
# end
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
# Sample resource route with sub-resources:
|
|
35
|
+
# resources :products do
|
|
36
|
+
# resources :comments, :sales
|
|
37
|
+
# resource :seller
|
|
38
|
+
# end
|
|
39
|
+
|
|
40
|
+
# Sample resource route with more complex sub-resources
|
|
41
|
+
# resources :products do
|
|
42
|
+
# resources :comments
|
|
43
|
+
# resources :sales do
|
|
44
|
+
# get 'recent', :on => :collection
|
|
45
|
+
# end
|
|
46
|
+
# end
|
|
47
|
+
|
|
48
|
+
# Sample resource route within a namespace:
|
|
49
|
+
# namespace :admin do
|
|
50
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
|
51
|
+
# # (app/controllers/admin/products_controller.rb)
|
|
52
|
+
# resources :products
|
|
53
|
+
# end
|
|
54
|
+
|
|
55
|
+
# You can have the root of your site routed with "root"
|
|
56
|
+
# just remember to delete public/index.html.
|
|
57
|
+
# root :to => 'welcome#index'
|
|
58
|
+
|
|
59
|
+
# See how all your routes lay out with "rake routes"
|
|
60
|
+
|
|
61
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
|
62
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
|
63
|
+
# match ':controller(/:action(/:id))(.:format)'
|
|
64
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
5
|
+
#
|
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
|
7
|
+
# database schema. If you need to create the application database on another
|
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
|
11
|
+
#
|
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
|
13
|
+
|
|
14
|
+
ActiveRecord::Schema.define(:version => 20131104031829) do
|
|
15
|
+
|
|
16
|
+
create_table "projects", :force => true do |t|
|
|
17
|
+
t.string "name"
|
|
18
|
+
t.text "description"
|
|
19
|
+
t.integer "priority"
|
|
20
|
+
t.datetime "created_at", :null => false
|
|
21
|
+
t.datetime "updated_at", :null => false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
create_table "tasks", :force => true do |t|
|
|
25
|
+
t.string "name"
|
|
26
|
+
t.text "description"
|
|
27
|
+
t.integer "project_id"
|
|
28
|
+
t.datetime "created_at", :null => false
|
|
29
|
+
t.datetime "updated_at", :null => false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
10.times do |i|
|
|
2
|
+
project = Project.create(
|
|
3
|
+
name: "Project #{i+1}",
|
|
4
|
+
priority: i**2,
|
|
5
|
+
description: "Project #{i+1} has a long description." * 8
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
4.times do |j|
|
|
9
|
+
Task.create(
|
|
10
|
+
name: "Task #{j+1}",
|
|
11
|
+
project_id: project.id,
|
|
12
|
+
description: "Task #{j+1} in Project #{i} has a long description" * 5
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class ProjectsControllerTest < ActionController::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@project = projects(:one)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "should get index" do
|
|
9
|
+
get :index
|
|
10
|
+
assert_response :success
|
|
11
|
+
assert_not_nil assigns(:projects)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "should get new" do
|
|
15
|
+
get :new
|
|
16
|
+
assert_response :success
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "should create project" do
|
|
20
|
+
assert_difference('Project.count') do
|
|
21
|
+
post :create, project: { description: @project.description, name: @project.name, priority: @project.priority }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
assert_redirected_to project_path(assigns(:project))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "should show project" do
|
|
28
|
+
get :show, id: @project
|
|
29
|
+
assert_response :success
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should get edit" do
|
|
33
|
+
get :edit, id: @project
|
|
34
|
+
assert_response :success
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "should update project" do
|
|
38
|
+
put :update, id: @project, project: { description: @project.description, name: @project.name, priority: @project.priority }
|
|
39
|
+
assert_redirected_to project_path(assigns(:project))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "should destroy project" do
|
|
43
|
+
assert_difference('Project.count', -1) do
|
|
44
|
+
delete :destroy, id: @project
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
assert_redirected_to projects_path
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class TasksControllerTest < ActionController::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@task = tasks(:one)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "should get index" do
|
|
9
|
+
get :index
|
|
10
|
+
assert_response :success
|
|
11
|
+
assert_not_nil assigns(:tasks)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test "should get new" do
|
|
15
|
+
get :new
|
|
16
|
+
assert_response :success
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "should create task" do
|
|
20
|
+
assert_difference('Task.count') do
|
|
21
|
+
post :create, task: { description: @task.description, name: @task.name, project_id: @task.project_id }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
assert_redirected_to task_path(assigns(:task))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
test "should show task" do
|
|
28
|
+
get :show, id: @task
|
|
29
|
+
assert_response :success
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "should get edit" do
|
|
33
|
+
get :edit, id: @task
|
|
34
|
+
assert_response :success
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "should update task" do
|
|
38
|
+
put :update, id: @task, task: { description: @task.description, name: @task.name, project_id: @task.project_id }
|
|
39
|
+
assert_redirected_to task_path(assigns(:task))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "should destroy task" do
|
|
43
|
+
assert_difference('Task.count', -1) do
|
|
44
|
+
delete :destroy, id: @task
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
assert_redirected_to tasks_path
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'rails/performance_test_help'
|
|
3
|
+
|
|
4
|
+
class BrowsingTest < ActionDispatch::PerformanceTest
|
|
5
|
+
# Refer to the documentation for all available options
|
|
6
|
+
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
|
|
7
|
+
# :output => 'tmp/performance', :formats => [:flat] }
|
|
8
|
+
|
|
9
|
+
def test_homepage
|
|
10
|
+
get '/'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
|
7
|
+
#
|
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
9
|
+
# -- they do not yet inherit this setting
|
|
10
|
+
fixtures :all
|
|
11
|
+
|
|
12
|
+
# Add more helper methods to be used by all tests here...
|
|
13
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
class ProjectsController < ApplicationController
|
|
2
|
+
before_action :set_project, only: [:show, :edit, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /projects
|
|
5
|
+
# GET /projects.json
|
|
6
|
+
def index
|
|
7
|
+
@projects = Project.all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# GET /projects/1
|
|
11
|
+
# GET /projects/1.json
|
|
12
|
+
def show
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# GET /projects/new
|
|
16
|
+
def new
|
|
17
|
+
@project = Project.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# GET /projects/1/edit
|
|
21
|
+
def edit
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# POST /projects
|
|
25
|
+
# POST /projects.json
|
|
26
|
+
def create
|
|
27
|
+
@project = Project.new(project_params)
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
if @project.save
|
|
31
|
+
format.html { redirect_to @project, notice: 'Project was successfully created.' }
|
|
32
|
+
format.json { render action: 'show', status: :created, location: @project }
|
|
33
|
+
else
|
|
34
|
+
format.html { render action: 'new' }
|
|
35
|
+
format.json { render json: @project.errors, status: :unprocessable_entity }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# PATCH/PUT /projects/1
|
|
41
|
+
# PATCH/PUT /projects/1.json
|
|
42
|
+
def update
|
|
43
|
+
respond_to do |format|
|
|
44
|
+
if @project.update(project_params)
|
|
45
|
+
format.html { redirect_to @project, notice: 'Project was successfully updated.' }
|
|
46
|
+
format.json { head :no_content }
|
|
47
|
+
else
|
|
48
|
+
format.html { render action: 'edit' }
|
|
49
|
+
format.json { render json: @project.errors, status: :unprocessable_entity }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# DELETE /projects/1
|
|
55
|
+
# DELETE /projects/1.json
|
|
56
|
+
def destroy
|
|
57
|
+
@project.destroy
|
|
58
|
+
respond_to do |format|
|
|
59
|
+
format.html { redirect_to projects_url }
|
|
60
|
+
format.json { head :no_content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
66
|
+
def set_project
|
|
67
|
+
@project = Project.find(params[:id])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
|
71
|
+
def project_params
|
|
72
|
+
params.require(:project).permit(:name, :priority, :description)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
class TasksController < ApplicationController
|
|
2
|
+
before_action :set_task, only: [:show, :edit, :update, :destroy]
|
|
3
|
+
|
|
4
|
+
# GET /tasks
|
|
5
|
+
# GET /tasks.json
|
|
6
|
+
def index
|
|
7
|
+
@tasks = Task.all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# GET /tasks/1
|
|
11
|
+
# GET /tasks/1.json
|
|
12
|
+
def show
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# GET /tasks/new
|
|
16
|
+
def new
|
|
17
|
+
@task = Task.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# GET /tasks/1/edit
|
|
21
|
+
def edit
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# POST /tasks
|
|
25
|
+
# POST /tasks.json
|
|
26
|
+
def create
|
|
27
|
+
@task = Task.new(task_params)
|
|
28
|
+
|
|
29
|
+
respond_to do |format|
|
|
30
|
+
if @task.save
|
|
31
|
+
format.html { redirect_to @task, notice: 'Task was successfully created.' }
|
|
32
|
+
format.json { render action: 'show', status: :created, location: @task }
|
|
33
|
+
else
|
|
34
|
+
format.html { render action: 'new' }
|
|
35
|
+
format.json { render json: @task.errors, status: :unprocessable_entity }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# PATCH/PUT /tasks/1
|
|
41
|
+
# PATCH/PUT /tasks/1.json
|
|
42
|
+
def update
|
|
43
|
+
respond_to do |format|
|
|
44
|
+
if @task.update(task_params)
|
|
45
|
+
format.html { redirect_to @task, notice: 'Task was successfully updated.' }
|
|
46
|
+
format.json { head :no_content }
|
|
47
|
+
else
|
|
48
|
+
format.html { render action: 'edit' }
|
|
49
|
+
format.json { render json: @task.errors, status: :unprocessable_entity }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# DELETE /tasks/1
|
|
55
|
+
# DELETE /tasks/1.json
|
|
56
|
+
def destroy
|
|
57
|
+
@task.destroy
|
|
58
|
+
respond_to do |format|
|
|
59
|
+
format.html { redirect_to tasks_url }
|
|
60
|
+
format.json { head :no_content }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
66
|
+
def set_task
|
|
67
|
+
@task = Task.find(params[:id])
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
|
71
|
+
def task_params
|
|
72
|
+
params.require(:task).permit(:name, :description, :project_id)
|
|
73
|
+
end
|
|
74
|
+
end
|