sandboxy 2.0.0 → 3.0.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +26 -36
- data/{examples/rails_example/app → app}/models/sandbox.rb +1 -1
- data/lib/generators/sandboxy_generator.rb +0 -4
- data/lib/generators/templates/initializer.rb +7 -7
- data/lib/generators/templates/migration.rb.erb +4 -9
- data/lib/sandboxy.rb +2 -9
- data/lib/sandboxy/configuration.rb +37 -10
- data/lib/sandboxy/engine.rb +6 -0
- data/lib/sandboxy/middleware.rb +3 -3
- data/lib/sandboxy/railtie.rb +7 -6
- data/lib/sandboxy/sandboxed.rb +69 -19
- data/lib/sandboxy/version.rb +1 -1
- metadata +5 -197
- data/.github/issue_template.md +0 -14
- data/.github/pull_request_template.md +0 -21
- data/.gitignore +0 -8
- data/.travis.yml +0 -3
- data/CODE_OF_CONDUCT.md +0 -46
- data/CONTRIBUTING.md +0 -1
- data/DEPRECATIONS.md +0 -5
- data/Gemfile +0 -9
- data/INSTALL.md +0 -3
- data/Rakefile +0 -15
- data/examples/rails_example/.gitignore +0 -23
- data/examples/rails_example/Gemfile +0 -54
- data/examples/rails_example/README.md +0 -24
- data/examples/rails_example/Rakefile +0 -6
- data/examples/rails_example/app/api/books/api.rb +0 -33
- data/examples/rails_example/app/assets/config/manifest.js +0 -3
- data/examples/rails_example/app/assets/images/.keep +0 -0
- data/examples/rails_example/app/assets/javascripts/application.js +0 -15
- data/examples/rails_example/app/assets/javascripts/applications.coffee +0 -3
- data/examples/rails_example/app/assets/javascripts/authors.coffee +0 -3
- data/examples/rails_example/app/assets/javascripts/books.coffee +0 -3
- data/examples/rails_example/app/assets/javascripts/cable.js +0 -13
- data/examples/rails_example/app/assets/javascripts/channels/.keep +0 -0
- data/examples/rails_example/app/assets/javascripts/libraries.coffee +0 -3
- data/examples/rails_example/app/assets/javascripts/sandbox.coffee +0 -3
- data/examples/rails_example/app/assets/stylesheets/application.css +0 -15
- data/examples/rails_example/app/assets/stylesheets/applications.scss +0 -3
- data/examples/rails_example/app/assets/stylesheets/authors.scss +0 -3
- data/examples/rails_example/app/assets/stylesheets/books.scss +0 -3
- data/examples/rails_example/app/assets/stylesheets/libraries.scss +0 -3
- data/examples/rails_example/app/assets/stylesheets/sandbox.scss +0 -3
- data/examples/rails_example/app/assets/stylesheets/scaffolds.scss +0 -84
- data/examples/rails_example/app/channels/application_cable/channel.rb +0 -4
- data/examples/rails_example/app/channels/application_cable/connection.rb +0 -4
- data/examples/rails_example/app/controllers/application_controller.rb +0 -7
- data/examples/rails_example/app/controllers/applications_controller.rb +0 -74
- data/examples/rails_example/app/controllers/authors_controller.rb +0 -77
- data/examples/rails_example/app/controllers/books_controller.rb +0 -77
- data/examples/rails_example/app/controllers/concerns/.keep +0 -0
- data/examples/rails_example/app/controllers/libraries_controller.rb +0 -77
- data/examples/rails_example/app/controllers/sandbox_controller.rb +0 -6
- data/examples/rails_example/app/helpers/application_helper.rb +0 -2
- data/examples/rails_example/app/helpers/applications_helper.rb +0 -2
- data/examples/rails_example/app/helpers/authors_helper.rb +0 -2
- data/examples/rails_example/app/helpers/books_helper.rb +0 -2
- data/examples/rails_example/app/helpers/libraries_helper.rb +0 -2
- data/examples/rails_example/app/helpers/sandbox_helper.rb +0 -2
- data/examples/rails_example/app/jobs/application_job.rb +0 -2
- data/examples/rails_example/app/mailers/application_mailer.rb +0 -4
- data/examples/rails_example/app/models/application.rb +0 -14
- data/examples/rails_example/app/models/application_record.rb +0 -3
- data/examples/rails_example/app/models/author.rb +0 -2
- data/examples/rails_example/app/models/book.rb +0 -2
- data/examples/rails_example/app/models/concerns/.keep +0 -0
- data/examples/rails_example/app/models/library.rb +0 -2
- data/examples/rails_example/app/views/applications/_application.json.jbuilder +0 -2
- data/examples/rails_example/app/views/applications/_form.html.erb +0 -19
- data/examples/rails_example/app/views/applications/edit.html.erb +0 -6
- data/examples/rails_example/app/views/applications/index.html.erb +0 -25
- data/examples/rails_example/app/views/applications/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/applications/new.html.erb +0 -5
- data/examples/rails_example/app/views/applications/show.html.erb +0 -7
- data/examples/rails_example/app/views/applications/show.json.jbuilder +0 -1
- data/examples/rails_example/app/views/authors/_author.json.jbuilder +0 -2
- data/examples/rails_example/app/views/authors/_form.html.erb +0 -19
- data/examples/rails_example/app/views/authors/edit.html.erb +0 -6
- data/examples/rails_example/app/views/authors/index.html.erb +0 -25
- data/examples/rails_example/app/views/authors/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/authors/new.html.erb +0 -5
- data/examples/rails_example/app/views/authors/show.html.erb +0 -4
- data/examples/rails_example/app/views/authors/show.json.jbuilder +0 -1
- data/examples/rails_example/app/views/books/_book.json.jbuilder +0 -2
- data/examples/rails_example/app/views/books/_form.html.erb +0 -19
- data/examples/rails_example/app/views/books/edit.html.erb +0 -6
- data/examples/rails_example/app/views/books/index.html.erb +0 -25
- data/examples/rails_example/app/views/books/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/books/new.html.erb +0 -5
- data/examples/rails_example/app/views/books/show.html.erb +0 -4
- data/examples/rails_example/app/views/books/show.json.jbuilder +0 -1
- data/examples/rails_example/app/views/layouts/application.html.erb +0 -14
- data/examples/rails_example/app/views/layouts/mailer.html.erb +0 -13
- data/examples/rails_example/app/views/layouts/mailer.text.erb +0 -1
- data/examples/rails_example/app/views/libraries/_form.html.erb +0 -19
- data/examples/rails_example/app/views/libraries/_library.json.jbuilder +0 -2
- data/examples/rails_example/app/views/libraries/edit.html.erb +0 -6
- data/examples/rails_example/app/views/libraries/index.html.erb +0 -25
- data/examples/rails_example/app/views/libraries/index.json.jbuilder +0 -1
- data/examples/rails_example/app/views/libraries/new.html.erb +0 -5
- data/examples/rails_example/app/views/libraries/show.html.erb +0 -4
- data/examples/rails_example/app/views/libraries/show.json.jbuilder +0 -1
- data/examples/rails_example/bin/bundle +0 -3
- data/examples/rails_example/bin/rails +0 -4
- data/examples/rails_example/bin/rake +0 -4
- data/examples/rails_example/bin/setup +0 -38
- data/examples/rails_example/bin/update +0 -29
- data/examples/rails_example/bin/yarn +0 -11
- data/examples/rails_example/config.ru +0 -5
- data/examples/rails_example/config/application.rb +0 -18
- data/examples/rails_example/config/boot.rb +0 -3
- data/examples/rails_example/config/cable.yml +0 -10
- data/examples/rails_example/config/database.yml +0 -25
- data/examples/rails_example/config/environment.rb +0 -5
- data/examples/rails_example/config/environments/development.rb +0 -54
- data/examples/rails_example/config/environments/production.rb +0 -91
- data/examples/rails_example/config/environments/test.rb +0 -42
- data/examples/rails_example/config/initializers/application_controller_renderer.rb +0 -6
- data/examples/rails_example/config/initializers/assets.rb +0 -14
- data/examples/rails_example/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/rails_example/config/initializers/cookies_serializer.rb +0 -5
- data/examples/rails_example/config/initializers/filter_parameter_logging.rb +0 -4
- data/examples/rails_example/config/initializers/grape.rb +0 -2
- data/examples/rails_example/config/initializers/inflections.rb +0 -16
- data/examples/rails_example/config/initializers/mime_types.rb +0 -4
- data/examples/rails_example/config/initializers/sandboxy.rb +0 -13
- data/examples/rails_example/config/initializers/wrap_parameters.rb +0 -14
- data/examples/rails_example/config/locales/en.yml +0 -33
- data/examples/rails_example/config/puma.rb +0 -56
- data/examples/rails_example/config/routes.rb +0 -13
- data/examples/rails_example/config/secrets.yml +0 -32
- data/examples/rails_example/db/migrate/20170827184048_create_books.rb +0 -9
- data/examples/rails_example/db/migrate/20170827184054_create_authors.rb +0 -9
- data/examples/rails_example/db/migrate/20170827184106_create_libraries.rb +0 -9
- data/examples/rails_example/db/migrate/20170827184304_create_applications.rb +0 -11
- data/examples/rails_example/db/migrate/20170827190815_sandboxy_migration.rb +0 -14
- data/examples/rails_example/db/schema.rb +0 -50
- data/examples/rails_example/db/seeds.rb +0 -7
- data/examples/rails_example/lib/assets/.keep +0 -0
- data/examples/rails_example/lib/tasks/.keep +0 -0
- data/examples/rails_example/package.json +0 -5
- data/examples/rails_example/public/404.html +0 -67
- data/examples/rails_example/public/422.html +0 -67
- data/examples/rails_example/public/500.html +0 -66
- data/examples/rails_example/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/rails_example/public/apple-touch-icon.png +0 -0
- data/examples/rails_example/public/favicon.ico +0 -0
- data/examples/rails_example/public/robots.txt +0 -1
- data/examples/rails_example/test/application_system_test_case.rb +0 -5
- data/examples/rails_example/test/controllers/.keep +0 -0
- data/examples/rails_example/test/controllers/applications_controller_test.rb +0 -48
- data/examples/rails_example/test/controllers/authors_controller_test.rb +0 -48
- data/examples/rails_example/test/controllers/books_controller_test.rb +0 -48
- data/examples/rails_example/test/controllers/libraries_controller_test.rb +0 -48
- data/examples/rails_example/test/controllers/sandbox_controller_test.rb +0 -7
- data/examples/rails_example/test/fixtures/.keep +0 -0
- data/examples/rails_example/test/fixtures/applications.yml +0 -11
- data/examples/rails_example/test/fixtures/authors.yml +0 -11
- data/examples/rails_example/test/fixtures/books.yml +0 -11
- data/examples/rails_example/test/fixtures/files/.keep +0 -0
- data/examples/rails_example/test/fixtures/libraries.yml +0 -11
- data/examples/rails_example/test/helpers/.keep +0 -0
- data/examples/rails_example/test/integration/.keep +0 -0
- data/examples/rails_example/test/mailers/.keep +0 -0
- data/examples/rails_example/test/models/.keep +0 -0
- data/examples/rails_example/test/models/application_test.rb +0 -7
- data/examples/rails_example/test/models/author_test.rb +0 -7
- data/examples/rails_example/test/models/book_test.rb +0 -7
- data/examples/rails_example/test/models/library_test.rb +0 -7
- data/examples/rails_example/test/system/.keep +0 -0
- data/examples/rails_example/test/system/applications_test.rb +0 -9
- data/examples/rails_example/test/system/authors_test.rb +0 -9
- data/examples/rails_example/test/system/books_test.rb +0 -9
- data/examples/rails_example/test/system/libraries_test.rb +0 -9
- data/examples/rails_example/test/test_helper.rb +0 -9
- data/examples/rails_example/tmp/.keep +0 -0
- data/examples/rails_example/vendor/.keep +0 -0
- data/init.rb +0 -1
- data/lib/generators/templates/model.rb +0 -7
- data/sandboxy.gemspec +0 -28
- data/test/dummy30/Gemfile +0 -1
- data/test/dummy30/Rakefile +0 -4
- data/test/dummy30/app/models/application_record.rb +0 -3
- data/test/dummy30/app/models/shared_sandbox.rb +0 -4
- data/test/dummy30/app/models/some.rb +0 -3
- data/test/dummy30/app/models/user.rb +0 -3
- data/test/dummy30/config.ru +0 -2
- data/test/dummy30/config/application.rb +0 -14
- data/test/dummy30/config/boot.rb +0 -10
- data/test/dummy30/config/database.yml +0 -6
- data/test/dummy30/config/environment.rb +0 -5
- data/test/dummy30/config/environments/development.rb +0 -7
- data/test/dummy30/config/environments/test.rb +0 -6
- data/test/dummy30/config/initializers/sandboxy.rb +0 -13
- data/test/dummy30/config/initializers/secret_token.rb +0 -1
- data/test/dummy30/config/initializers/session_store.rb +0 -1
- data/test/dummy30/config/locales/en.yml +0 -2
- data/test/dummy30/config/routes.rb +0 -2
- data/test/dummy30/config/sandboxy.yml +0 -1
- data/test/factories/somes.rb +0 -17
- data/test/factories/users.rb +0 -5
- data/test/sandbox_test.rb +0 -51
- data/test/sandboxed_test.rb +0 -58
- data/test/schema.rb +0 -18
- data/test/test_helper.rb +0 -20
@@ -1,24 +0,0 @@
|
|
1
|
-
# README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Books
|
2
|
-
class API < Grape::API
|
3
|
-
|
4
|
-
version 'v1', using: :path, vendor: 'books'
|
5
|
-
format :json
|
6
|
-
|
7
|
-
helpers do
|
8
|
-
def authenticate! access_token
|
9
|
-
if current_app ||= ::Application.find_by(access_token: access_token)
|
10
|
-
$sandbox = false
|
11
|
-
elsif current_app ||= ::Application.find_by(sandbox_access_token: access_token)
|
12
|
-
$sandbox = true
|
13
|
-
else
|
14
|
-
error!
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
rescue_from :all
|
20
|
-
|
21
|
-
resource :books do
|
22
|
-
params do
|
23
|
-
requires :access_token, String
|
24
|
-
end
|
25
|
-
|
26
|
-
get :index do
|
27
|
-
authenticate! params[:access_token]
|
28
|
-
::Book.all.limit(5)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
|
5
|
-
// vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require rails-ujs
|
14
|
-
//= require turbolinks
|
15
|
-
//= require_tree .
|
@@ -1,13 +0,0 @@
|
|
1
|
-
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
-
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
-
//
|
4
|
-
//= require action_cable
|
5
|
-
//= require_self
|
6
|
-
//= require_tree ./channels
|
7
|
-
|
8
|
-
(function() {
|
9
|
-
this.App || (this.App = {});
|
10
|
-
|
11
|
-
App.cable = ActionCable.createConsumer();
|
12
|
-
|
13
|
-
}).call(this);
|
File without changes
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
-
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
-
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
-
* It is generally better to create a new file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,84 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
background-color: #fff;
|
3
|
-
color: #333;
|
4
|
-
margin: 33px;
|
5
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
6
|
-
font-size: 13px;
|
7
|
-
line-height: 18px;
|
8
|
-
}
|
9
|
-
|
10
|
-
p, ol, ul, td {
|
11
|
-
font-family: verdana, arial, helvetica, sans-serif;
|
12
|
-
font-size: 13px;
|
13
|
-
line-height: 18px;
|
14
|
-
}
|
15
|
-
|
16
|
-
pre {
|
17
|
-
background-color: #eee;
|
18
|
-
padding: 10px;
|
19
|
-
font-size: 11px;
|
20
|
-
}
|
21
|
-
|
22
|
-
a {
|
23
|
-
color: #000;
|
24
|
-
|
25
|
-
&:visited {
|
26
|
-
color: #666;
|
27
|
-
}
|
28
|
-
|
29
|
-
&:hover {
|
30
|
-
color: #fff;
|
31
|
-
background-color: #000;
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
th {
|
36
|
-
padding-bottom: 5px;
|
37
|
-
}
|
38
|
-
|
39
|
-
td {
|
40
|
-
padding: 0 5px 7px;
|
41
|
-
}
|
42
|
-
|
43
|
-
div {
|
44
|
-
&.field, &.actions {
|
45
|
-
margin-bottom: 10px;
|
46
|
-
}
|
47
|
-
}
|
48
|
-
|
49
|
-
#notice {
|
50
|
-
color: green;
|
51
|
-
}
|
52
|
-
|
53
|
-
.field_with_errors {
|
54
|
-
padding: 2px;
|
55
|
-
background-color: red;
|
56
|
-
display: table;
|
57
|
-
}
|
58
|
-
|
59
|
-
#error_explanation {
|
60
|
-
width: 450px;
|
61
|
-
border: 2px solid red;
|
62
|
-
padding: 7px 7px 0;
|
63
|
-
margin-bottom: 20px;
|
64
|
-
background-color: #f0f0f0;
|
65
|
-
|
66
|
-
h2 {
|
67
|
-
text-align: left;
|
68
|
-
font-weight: bold;
|
69
|
-
padding: 5px 5px 5px 15px;
|
70
|
-
font-size: 12px;
|
71
|
-
margin: -7px -7px 0;
|
72
|
-
background-color: #c00;
|
73
|
-
color: #fff;
|
74
|
-
}
|
75
|
-
|
76
|
-
ul li {
|
77
|
-
font-size: 12px;
|
78
|
-
list-style: square;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
label {
|
83
|
-
display: block;
|
84
|
-
}
|
@@ -1,74 +0,0 @@
|
|
1
|
-
class ApplicationsController < ApplicationController
|
2
|
-
before_action :set_application, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
# GET /applications
|
5
|
-
# GET /applications.json
|
6
|
-
def index
|
7
|
-
@applications = Application.all
|
8
|
-
end
|
9
|
-
|
10
|
-
# GET /applications/1
|
11
|
-
# GET /applications/1.json
|
12
|
-
def show
|
13
|
-
end
|
14
|
-
|
15
|
-
# GET /applications/new
|
16
|
-
def new
|
17
|
-
@application = Application.new
|
18
|
-
end
|
19
|
-
|
20
|
-
# GET /applications/1/edit
|
21
|
-
def edit
|
22
|
-
end
|
23
|
-
|
24
|
-
# POST /applications
|
25
|
-
# POST /applications.json
|
26
|
-
def create
|
27
|
-
@application = Application.new(application_params)
|
28
|
-
|
29
|
-
respond_to do |format|
|
30
|
-
if @application.save
|
31
|
-
format.html { redirect_to @application, notice: 'Application was successfully created.' }
|
32
|
-
format.json { render :show, status: :created, location: @application }
|
33
|
-
else
|
34
|
-
format.html { render :new }
|
35
|
-
format.json { render json: @application.errors, status: :unprocessable_entity }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# PATCH/PUT /applications/1
|
41
|
-
# PATCH/PUT /applications/1.json
|
42
|
-
def update
|
43
|
-
respond_to do |format|
|
44
|
-
if @application.update(application_params)
|
45
|
-
format.html { redirect_to @application, notice: 'Application was successfully updated.' }
|
46
|
-
format.json { render :show, status: :ok, location: @application }
|
47
|
-
else
|
48
|
-
format.html { render :edit }
|
49
|
-
format.json { render json: @application.errors, status: :unprocessable_entity }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# DELETE /applications/1
|
55
|
-
# DELETE /applications/1.json
|
56
|
-
def destroy
|
57
|
-
@application.destroy
|
58
|
-
respond_to do |format|
|
59
|
-
format.html { redirect_to applications_url, notice: 'Application was successfully destroyed.' }
|
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_application
|
67
|
-
@application = Application.find(params[:id])
|
68
|
-
end
|
69
|
-
|
70
|
-
# Never trust parameters from the scary internet, only allow the white list through.
|
71
|
-
def application_params
|
72
|
-
params.fetch(:application, {})
|
73
|
-
end
|
74
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
class AuthorsController < ApplicationController
|
2
|
-
before_action :set_author, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
# GET /authors
|
5
|
-
# GET /authors.json
|
6
|
-
def index
|
7
|
-
$sandbox = session[:sandbox]
|
8
|
-
@authors = Author.all
|
9
|
-
end
|
10
|
-
|
11
|
-
# GET /authors/1
|
12
|
-
# GET /authors/1.json
|
13
|
-
def show
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /authors/new
|
17
|
-
def new
|
18
|
-
$sandbox = session[:sandbox]
|
19
|
-
@author = Author.new
|
20
|
-
end
|
21
|
-
|
22
|
-
# GET /authors/1/edit
|
23
|
-
def edit
|
24
|
-
end
|
25
|
-
|
26
|
-
# POST /authors
|
27
|
-
# POST /authors.json
|
28
|
-
def create
|
29
|
-
$sandbox = session[:sandbox]
|
30
|
-
@author = Author.new(author_params)
|
31
|
-
|
32
|
-
respond_to do |format|
|
33
|
-
if @author.save
|
34
|
-
format.html { redirect_to @author, notice: 'Author was successfully created.' }
|
35
|
-
format.json { render :show, status: :created, location: @author }
|
36
|
-
else
|
37
|
-
format.html { render :new }
|
38
|
-
format.json { render json: @author.errors, status: :unprocessable_entity }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# PATCH/PUT /authors/1
|
44
|
-
# PATCH/PUT /authors/1.json
|
45
|
-
def update
|
46
|
-
respond_to do |format|
|
47
|
-
if @author.update(author_params)
|
48
|
-
format.html { redirect_to @author, notice: 'Author was successfully updated.' }
|
49
|
-
format.json { render :show, status: :ok, location: @author }
|
50
|
-
else
|
51
|
-
format.html { render :edit }
|
52
|
-
format.json { render json: @author.errors, status: :unprocessable_entity }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# DELETE /authors/1
|
58
|
-
# DELETE /authors/1.json
|
59
|
-
def destroy
|
60
|
-
@author.destroy
|
61
|
-
respond_to do |format|
|
62
|
-
format.html { redirect_to authors_url, notice: 'Author was successfully destroyed.' }
|
63
|
-
format.json { head :no_content }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
# Use callbacks to share common setup or constraints between actions.
|
69
|
-
def set_author
|
70
|
-
@author = Author.find(params[:id])
|
71
|
-
end
|
72
|
-
|
73
|
-
# Never trust parameters from the scary internet, only allow the white list through.
|
74
|
-
def author_params
|
75
|
-
params.fetch(:author, {})
|
76
|
-
end
|
77
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
class BooksController < ApplicationController
|
2
|
-
before_action :set_book, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
# GET /books
|
5
|
-
# GET /books.json
|
6
|
-
def index
|
7
|
-
$sandbox = session[:sandbox]
|
8
|
-
@books = Book.all
|
9
|
-
end
|
10
|
-
|
11
|
-
# GET /books/1
|
12
|
-
# GET /books/1.json
|
13
|
-
def show
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET /books/new
|
17
|
-
def new
|
18
|
-
$sandbox = session[:sandbox]
|
19
|
-
@book = Book.new
|
20
|
-
end
|
21
|
-
|
22
|
-
# GET /books/1/edit
|
23
|
-
def edit
|
24
|
-
end
|
25
|
-
|
26
|
-
# POST /books
|
27
|
-
# POST /books.json
|
28
|
-
def create
|
29
|
-
$sandbox = session[:sandbox]
|
30
|
-
@book = Book.new(book_params)
|
31
|
-
|
32
|
-
respond_to do |format|
|
33
|
-
if @book.save
|
34
|
-
format.html { redirect_to @book, notice: 'Book was successfully created.' }
|
35
|
-
format.json { render :show, status: :created, location: @book }
|
36
|
-
else
|
37
|
-
format.html { render :new }
|
38
|
-
format.json { render json: @book.errors, status: :unprocessable_entity }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# PATCH/PUT /books/1
|
44
|
-
# PATCH/PUT /books/1.json
|
45
|
-
def update
|
46
|
-
respond_to do |format|
|
47
|
-
if @book.update(book_params)
|
48
|
-
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
|
49
|
-
format.json { render :show, status: :ok, location: @book }
|
50
|
-
else
|
51
|
-
format.html { render :edit }
|
52
|
-
format.json { render json: @book.errors, status: :unprocessable_entity }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# DELETE /books/1
|
58
|
-
# DELETE /books/1.json
|
59
|
-
def destroy
|
60
|
-
@book.destroy
|
61
|
-
respond_to do |format|
|
62
|
-
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
|
63
|
-
format.json { head :no_content }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
# Use callbacks to share common setup or constraints between actions.
|
69
|
-
def set_book
|
70
|
-
@book = Book.find(params[:id])
|
71
|
-
end
|
72
|
-
|
73
|
-
# Never trust parameters from the scary internet, only allow the white list through.
|
74
|
-
def book_params
|
75
|
-
params.fetch(:book, {})
|
76
|
-
end
|
77
|
-
end
|