railties 7.0.10 → 7.1.0.beta1
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 +565 -234
- data/MIT-LICENSE +1 -1
- data/RDOC_MAIN.md +99 -0
- data/README.rdoc +4 -4
- data/lib/minitest/rails_plugin.rb +63 -0
- data/lib/rails/api/task.rb +35 -4
- data/lib/rails/app_updater.rb +1 -1
- data/lib/rails/application/bootstrap.rb +12 -3
- data/lib/rails/application/configuration.rb +179 -67
- data/lib/rails/application/default_middleware_stack.rb +8 -2
- data/lib/rails/application/dummy_config.rb +19 -0
- data/lib/rails/application/finisher.rb +40 -33
- data/lib/rails/application.rb +116 -31
- data/lib/rails/backtrace_cleaner.rb +1 -1
- data/lib/rails/cli.rb +5 -2
- data/lib/rails/command/actions.rb +10 -12
- data/lib/rails/command/base.rb +55 -53
- data/lib/rails/command/environment_argument.rb +32 -16
- data/lib/rails/command/helpers/editor.rb +17 -12
- data/lib/rails/command.rb +84 -33
- data/lib/rails/commands/about/about_command.rb +14 -0
- data/lib/rails/commands/application/application_command.rb +2 -0
- data/lib/rails/commands/console/console_command.rb +14 -14
- data/lib/rails/commands/credentials/USAGE +53 -55
- data/lib/rails/commands/credentials/credentials_command/diffing.rb +5 -3
- data/lib/rails/commands/credentials/credentials_command.rb +64 -70
- data/lib/rails/commands/db/system/change/change_command.rb +2 -1
- data/lib/rails/commands/dbconsole/dbconsole_command.rb +25 -115
- data/lib/rails/commands/destroy/destroy_command.rb +3 -2
- data/lib/rails/commands/dev/dev_command.rb +1 -6
- data/lib/rails/commands/encrypted/USAGE +15 -20
- data/lib/rails/commands/encrypted/encrypted_command.rb +46 -35
- data/lib/rails/commands/gem_help/USAGE +16 -0
- data/lib/rails/commands/gem_help/gem_help_command.rb +13 -0
- data/lib/rails/commands/generate/generate_command.rb +2 -2
- data/lib/rails/commands/help/USAGE +13 -13
- data/lib/rails/commands/help/help_command.rb +21 -2
- data/lib/rails/commands/initializers/initializers_command.rb +1 -4
- data/lib/rails/commands/middleware/middleware_command.rb +17 -0
- data/lib/rails/commands/new/new_command.rb +2 -0
- data/lib/rails/commands/notes/notes_command.rb +2 -1
- data/lib/rails/commands/plugin/plugin_command.rb +2 -0
- data/lib/rails/commands/rake/rake_command.rb +25 -22
- data/lib/rails/commands/restart/restart_command.rb +14 -0
- data/lib/rails/commands/routes/routes_command.rb +13 -1
- data/lib/rails/commands/runner/USAGE +14 -12
- data/lib/rails/commands/runner/runner_command.rb +32 -20
- data/lib/rails/commands/secret/secret_command.rb +13 -0
- data/lib/rails/commands/secrets/USAGE +44 -49
- data/lib/rails/commands/secrets/secrets_command.rb +19 -38
- data/lib/rails/commands/server/server_command.rb +32 -31
- data/lib/rails/commands/test/USAGE +14 -0
- data/lib/rails/commands/test/test_command.rb +56 -14
- data/lib/rails/commands/unused_routes/unused_routes_command.rb +75 -0
- data/lib/rails/commands/version/version_command.rb +1 -0
- data/lib/rails/configuration.rb +5 -5
- data/lib/rails/console/app.rb +1 -4
- data/lib/rails/deprecator.rb +7 -0
- data/lib/rails/engine/configuration.rb +5 -0
- data/lib/rails/engine.rb +36 -16
- data/lib/rails/gem_version.rb +4 -4
- data/lib/rails/generators/actions.rb +6 -15
- data/lib/rails/generators/active_model.rb +14 -28
- data/lib/rails/generators/app_base.rb +353 -82
- data/lib/rails/generators/app_name.rb +3 -14
- data/lib/rails/generators/base.rb +17 -9
- data/lib/rails/generators/database.rb +19 -1
- data/lib/rails/generators/erb/mailer/templates/layout.html.erb.tt +1 -1
- data/lib/rails/generators/generated_attribute.rb +2 -1
- data/lib/rails/generators/migration.rb +1 -2
- data/lib/rails/generators/model_helpers.rb +2 -1
- data/lib/rails/generators/rails/app/USAGE +15 -6
- data/lib/rails/generators/rails/app/app_generator.rb +84 -60
- data/lib/rails/generators/rails/app/templates/Dockerfile.tt +107 -0
- data/lib/rails/generators/rails/app/templates/Gemfile.tt +9 -11
- data/lib/rails/generators/rails/app/templates/app/views/layouts/mailer.html.erb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/bin/setup.tt +10 -1
- data/lib/rails/generators/rails/app/templates/config/application.rb.tt +4 -17
- data/lib/rails/generators/rails/app/templates/config/databases/jdbcsqlite3.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml.tt +0 -2
- data/lib/rails/generators/rails/app/templates/config/databases/sqlite3.yml.tt +3 -3
- data/lib/rails/generators/rails/app/templates/config/databases/trilogy.yml.tt +59 -0
- data/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +10 -2
- data/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +28 -24
- data/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +11 -7
- data/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +2 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/content_security_policy.rb.tt +2 -2
- data/lib/rails/generators/rails/app/templates/config/initializers/cors.rb.tt +1 -1
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt +223 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/permissions_policy.rb.tt +11 -9
- data/lib/rails/generators/rails/app/templates/config/locales/en.yml +11 -13
- data/lib/rails/generators/rails/app/templates/config/puma.rb.tt +10 -19
- data/lib/rails/generators/rails/app/templates/config/routes.rb.tt +4 -0
- data/lib/rails/generators/rails/app/templates/db/seeds.rb.tt +6 -4
- data/lib/rails/generators/rails/app/templates/docker-entrypoint.tt +10 -0
- data/lib/rails/generators/rails/app/templates/dockerignore.tt +43 -0
- data/lib/rails/generators/rails/app/templates/gitignore.tt +1 -9
- data/lib/rails/generators/rails/app/templates/node-version.tt +1 -0
- data/lib/rails/generators/rails/app/templates/test/channels/application_cable/connection_test.rb.tt +10 -8
- data/lib/rails/generators/rails/app/templates/test/test_helper.rb.tt +9 -7
- data/lib/rails/generators/rails/application_record/application_record_generator.rb +4 -0
- data/lib/rails/generators/rails/benchmark/benchmark_generator.rb +2 -1
- data/lib/rails/generators/rails/controller/USAGE +12 -4
- data/lib/rails/generators/rails/controller/controller_generator.rb +5 -0
- data/lib/rails/generators/rails/controller/templates/controller.rb.tt +1 -1
- data/lib/rails/generators/rails/credentials/credentials_generator.rb +29 -24
- data/lib/rails/generators/rails/credentials/templates/credentials.yml.tt +8 -0
- data/lib/rails/generators/rails/encryption_key_file/encryption_key_file_generator.rb +1 -2
- data/lib/rails/generators/rails/migration/USAGE +21 -11
- data/lib/rails/generators/rails/model/model_generator.rb +4 -0
- data/lib/rails/generators/rails/plugin/USAGE +17 -6
- data/lib/rails/generators/rails/plugin/plugin_generator.rb +5 -15
- data/lib/rails/generators/rails/plugin/templates/Gemfile.tt +2 -2
- data/lib/rails/generators/rails/plugin/templates/MIT-LICENSE.tt +1 -1
- data/lib/rails/generators/rails/plugin/templates/bin/rails.tt +1 -17
- data/lib/rails/generators/rails/plugin/templates/gitignore.tt +0 -2
- data/lib/rails/generators/rails/plugin/templates/test/test_helper.rb.tt +4 -4
- data/lib/rails/generators/rails/resource/resource_generator.rb +6 -0
- data/lib/rails/generators/rails/scaffold/scaffold_generator.rb +2 -1
- data/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +1 -1
- data/lib/rails/generators/test_case.rb +2 -2
- data/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +1 -1
- data/lib/rails/generators/testing/{behaviour.rb → behavior.rb} +4 -1
- data/lib/rails/generators.rb +6 -14
- data/lib/rails/health_controller.rb +55 -0
- data/lib/rails/info.rb +1 -1
- data/lib/rails/info_controller.rb +31 -11
- data/lib/rails/mailers_controller.rb +15 -5
- data/lib/rails/rack/logger.rb +15 -12
- data/lib/rails/rackup/server.rb +15 -0
- data/lib/rails/railtie/configuration.rb +14 -1
- data/lib/rails/railtie.rb +18 -18
- data/lib/rails/ruby_version_check.rb +2 -0
- data/lib/rails/source_annotation_extractor.rb +67 -18
- data/lib/rails/tasks/engine.rake +8 -8
- data/lib/rails/tasks/framework.rake +4 -10
- data/lib/rails/tasks/log.rake +1 -1
- data/lib/rails/tasks/misc.rake +3 -14
- data/lib/rails/tasks/statistics.rake +5 -4
- data/lib/rails/tasks/tmp.rake +5 -5
- data/lib/rails/tasks/zeitwerk.rake +1 -1
- data/lib/rails/tasks.rb +0 -2
- data/lib/rails/templates/rails/mailers/email.html.erb +25 -0
- data/lib/rails/templates/rails/mailers/index.html.erb +14 -7
- data/lib/rails/templates/rails/mailers/mailer.html.erb +11 -5
- data/lib/rails/templates/rails/welcome/index.html.erb +1 -0
- data/lib/rails/test_help.rb +7 -7
- data/lib/rails/test_unit/line_filtering.rb +1 -1
- data/lib/rails/test_unit/reporter.rb +6 -2
- data/lib/rails/test_unit/runner.rb +36 -18
- data/lib/rails/test_unit/test_parser.rb +88 -0
- data/lib/rails/test_unit/testing.rake +13 -33
- data/lib/rails/version.rb +1 -1
- data/lib/rails.rb +15 -15
- metadata +69 -31
- data/RDOC_MAIN.rdoc +0 -97
- data/lib/rails/application/dummy_erb_compiler.rb +0 -18
- data/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_0.rb.tt +0 -143
- data/lib/rails/generators/rails/model/USAGE +0 -113
- data/lib/rails/tasks/middleware.rake +0 -9
- data/lib/rails/tasks/restart.rake +0 -9
data/lib/rails/configuration.rb
CHANGED
|
@@ -7,17 +7,17 @@ require "rails/rack"
|
|
|
7
7
|
|
|
8
8
|
module Rails
|
|
9
9
|
module Configuration
|
|
10
|
-
# MiddlewareStackProxy is a proxy for the Rails middleware stack that allows
|
|
10
|
+
# MiddlewareStackProxy is a proxy for the \Rails middleware stack that allows
|
|
11
11
|
# you to configure middlewares in your application. It works basically as a
|
|
12
12
|
# command recorder, saving each command to be applied after initialization
|
|
13
13
|
# over the default middleware stack, so you can add, swap, or remove any
|
|
14
|
-
# middleware in Rails.
|
|
14
|
+
# middleware in \Rails.
|
|
15
15
|
#
|
|
16
16
|
# You can add your own middlewares by using the +config.middleware.use+ method:
|
|
17
17
|
#
|
|
18
18
|
# config.middleware.use Magical::Unicorns
|
|
19
19
|
#
|
|
20
|
-
# This will put the
|
|
20
|
+
# This will put the +Magical::Unicorns+ middleware on the end of the stack.
|
|
21
21
|
# You can use +insert_before+ if you wish to add a middleware before another:
|
|
22
22
|
#
|
|
23
23
|
# config.middleware.insert_before Rack::Head, Magical::Unicorns
|
|
@@ -34,8 +34,8 @@ module Rails
|
|
|
34
34
|
#
|
|
35
35
|
# config.middleware.move_before ActionDispatch::Flash, Magical::Unicorns
|
|
36
36
|
#
|
|
37
|
-
# This will move the
|
|
38
|
-
#
|
|
37
|
+
# This will move the +Magical::Unicorns+ middleware before the
|
|
38
|
+
# +ActionDispatch::Flash+. You can also move it after:
|
|
39
39
|
#
|
|
40
40
|
# config.middleware.move_after ActionDispatch::Flash, Magical::Unicorns
|
|
41
41
|
#
|
data/lib/rails/console/app.rb
CHANGED
|
@@ -9,9 +9,7 @@ module Rails
|
|
|
9
9
|
# instance, pass a non-false value as the parameter.
|
|
10
10
|
def app(create = false)
|
|
11
11
|
@app_integration_instance = nil if create
|
|
12
|
-
@app_integration_instance ||= new_session
|
|
13
|
-
sess.host! "www.example.com"
|
|
14
|
-
end
|
|
12
|
+
@app_integration_instance ||= new_session
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
# create a new session. If a block is given, the new session will be yielded
|
|
@@ -19,7 +17,6 @@ module Rails
|
|
|
19
17
|
def new_session
|
|
20
18
|
app = Rails.application
|
|
21
19
|
session = ActionDispatch::Integration::Session.new(app)
|
|
22
|
-
yield session if block_given?
|
|
23
20
|
|
|
24
21
|
# This makes app.url_for and app.foo_path available in the console
|
|
25
22
|
session.extend(app.routes.url_helpers)
|
|
@@ -50,6 +50,9 @@ module Rails
|
|
|
50
50
|
paths.add "app/mailers", eager_load: true
|
|
51
51
|
paths.add "app/views"
|
|
52
52
|
|
|
53
|
+
# If you add more lib subdirectories here that should not be managed
|
|
54
|
+
# by the main autoloader, please update the config.autoload_lib call
|
|
55
|
+
# in the template that generates config/application.rb accordingly.
|
|
53
56
|
paths.add "lib", load_path: true
|
|
54
57
|
paths.add "lib/assets", glob: "*"
|
|
55
58
|
paths.add "lib/tasks", glob: "**/*.rake"
|
|
@@ -68,6 +71,8 @@ module Rails
|
|
|
68
71
|
paths.add "vendor", load_path: true
|
|
69
72
|
paths.add "vendor/assets", glob: "*"
|
|
70
73
|
|
|
74
|
+
paths.add "test/mailers/previews", autoload: true
|
|
75
|
+
|
|
71
76
|
paths
|
|
72
77
|
end
|
|
73
78
|
end
|
data/lib/rails/engine.rb
CHANGED
|
@@ -9,14 +9,13 @@ require "pathname"
|
|
|
9
9
|
require "thread"
|
|
10
10
|
|
|
11
11
|
module Rails
|
|
12
|
-
#
|
|
12
|
+
# +Rails::Engine+ allows you to wrap a specific \Rails application or subset of
|
|
13
13
|
# functionality and share it with other applications or within a larger packaged application.
|
|
14
14
|
# Every Rails::Application is just an engine, which allows for simple
|
|
15
15
|
# feature and application sharing.
|
|
16
16
|
#
|
|
17
|
-
# Any
|
|
18
|
-
# methods (like
|
|
19
|
-
# {generators}[rdoc-ref:Rails::Railtie::generators]) and configuration
|
|
17
|
+
# Any +Rails::Engine+ is also a Rails::Railtie, so the same
|
|
18
|
+
# methods (like <tt>rake_tasks</tt> and +generators+) and configuration
|
|
20
19
|
# options that are available in railties can also be used in engines.
|
|
21
20
|
#
|
|
22
21
|
# == Creating an Engine
|
|
@@ -117,7 +116,7 @@ module Rails
|
|
|
117
116
|
# An engine can also be a Rack application. It can be useful if you have a Rack application that
|
|
118
117
|
# you would like to provide with some of the +Engine+'s features.
|
|
119
118
|
#
|
|
120
|
-
# To do that, use the
|
|
119
|
+
# To do that, use the +endpoint+ method:
|
|
121
120
|
#
|
|
122
121
|
# module MyEngine
|
|
123
122
|
# class Engine < Rails::Engine
|
|
@@ -182,7 +181,7 @@ module Rails
|
|
|
182
181
|
# it's used as default <tt>:as</tt> option
|
|
183
182
|
# * rake task for installing migrations <tt>my_engine:install:migrations</tt>
|
|
184
183
|
#
|
|
185
|
-
# Engine name is set by default based on class name. For
|
|
184
|
+
# Engine name is set by default based on class name. For +MyEngine::Engine+ it will be
|
|
186
185
|
# <tt>my_engine_engine</tt>. You can change it manually using the <tt>engine_name</tt> method:
|
|
187
186
|
#
|
|
188
187
|
# module MyEngine
|
|
@@ -198,7 +197,7 @@ module Rails
|
|
|
198
197
|
# named routes from the application will be available to your engine's controllers as well.
|
|
199
198
|
#
|
|
200
199
|
# However, sometimes you want to isolate your engine from the application, especially if your engine
|
|
201
|
-
# has its own router. To do that, you simply need to call
|
|
200
|
+
# has its own router. To do that, you simply need to call +isolate_namespace+. This method requires
|
|
202
201
|
# you to pass a module where all your controllers, helpers, and models should be nested to:
|
|
203
202
|
#
|
|
204
203
|
# module MyEngine
|
|
@@ -232,14 +231,14 @@ module Rails
|
|
|
232
231
|
# end
|
|
233
232
|
#
|
|
234
233
|
# If +MyEngine+ is isolated, the routes above will point to
|
|
235
|
-
#
|
|
234
|
+
# +MyEngine::ArticlesController+. You also don't need to use longer
|
|
236
235
|
# URL helpers like +my_engine_articles_path+. Instead, you should simply use
|
|
237
236
|
# +articles_path+, like you would do with your main application.
|
|
238
237
|
#
|
|
239
238
|
# To make this behavior consistent with other parts of the framework,
|
|
240
239
|
# isolated engines also have an effect on ActiveModel::Naming. In a
|
|
241
|
-
# normal Rails app, when you use a namespaced model such as
|
|
242
|
-
#
|
|
240
|
+
# normal \Rails app, when you use a namespaced model such as
|
|
241
|
+
# +Namespace::Article+, ActiveModel::Naming will generate
|
|
243
242
|
# names with the prefix "namespace". In an isolated engine, the prefix will
|
|
244
243
|
# be omitted in URL helpers and form fields, for convenience.
|
|
245
244
|
#
|
|
@@ -253,7 +252,7 @@ module Rails
|
|
|
253
252
|
# Additionally, an isolated engine will set its own name according to its
|
|
254
253
|
# namespace, so <tt>MyEngine::Engine.engine_name</tt> will return
|
|
255
254
|
# "my_engine". It will also set +MyEngine.table_name_prefix+ to "my_engine_",
|
|
256
|
-
# meaning for example that
|
|
255
|
+
# meaning for example that +MyEngine::Article+ will use the
|
|
257
256
|
# +my_engine_articles+ database table by default.
|
|
258
257
|
#
|
|
259
258
|
# == Using Engine's routes outside Engine
|
|
@@ -328,7 +327,7 @@ module Rails
|
|
|
328
327
|
# To use engine's migrations in application you can use the rake task below, which copies them to
|
|
329
328
|
# application's dir:
|
|
330
329
|
#
|
|
331
|
-
#
|
|
330
|
+
# rake ENGINE_NAME:install:migrations
|
|
332
331
|
#
|
|
333
332
|
# Note that some of the migrations may be skipped if a migration with the same name already exists
|
|
334
333
|
# in application. In such a situation you must decide whether to leave that migration or rename the
|
|
@@ -451,7 +450,7 @@ module Rails
|
|
|
451
450
|
self
|
|
452
451
|
end
|
|
453
452
|
|
|
454
|
-
# Load Rails runner and invoke the registered hooks.
|
|
453
|
+
# Load \Rails runner and invoke the registered hooks.
|
|
455
454
|
# Check Rails::Railtie.runner for more info.
|
|
456
455
|
def load_runner(app = self)
|
|
457
456
|
run_runner_blocks(app)
|
|
@@ -466,7 +465,7 @@ module Rails
|
|
|
466
465
|
self
|
|
467
466
|
end
|
|
468
467
|
|
|
469
|
-
# Load Rails generators and invoke the registered hooks.
|
|
468
|
+
# Load \Rails generators and invoke the registered hooks.
|
|
470
469
|
# Check Rails::Railtie.generators for more info.
|
|
471
470
|
def load_generators(app = self)
|
|
472
471
|
require "rails/generators"
|
|
@@ -495,8 +494,7 @@ module Rails
|
|
|
495
494
|
def helpers
|
|
496
495
|
@helpers ||= begin
|
|
497
496
|
helpers = Module.new
|
|
498
|
-
|
|
499
|
-
ActionController::Base.modules_for_helpers(all).each do |mod|
|
|
497
|
+
AbstractController::Helpers.helper_modules_from_paths(helpers_paths).each do |mod|
|
|
500
498
|
helpers.include(mod)
|
|
501
499
|
end
|
|
502
500
|
helpers
|
|
@@ -588,6 +586,7 @@ module Rails
|
|
|
588
586
|
routing_paths = paths["config/routes.rb"].existent
|
|
589
587
|
external_paths = self.paths["config/routes"].paths
|
|
590
588
|
routes.draw_paths.concat(external_paths)
|
|
589
|
+
app.routes.draw_paths.concat(external_paths)
|
|
591
590
|
|
|
592
591
|
if routes? || routing_paths.any?
|
|
593
592
|
app.routes_reloader.paths.unshift(*routing_paths)
|
|
@@ -610,6 +609,22 @@ module Rails
|
|
|
610
609
|
end
|
|
611
610
|
end
|
|
612
611
|
|
|
612
|
+
initializer :add_mailer_preview_paths do
|
|
613
|
+
previews = paths["test/mailers/previews"].existent
|
|
614
|
+
unless previews.empty?
|
|
615
|
+
ActiveSupport.on_load(:action_mailer) { self.preview_paths |= previews }
|
|
616
|
+
end
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
initializer :add_fixture_paths do
|
|
620
|
+
next if is_a?(Rails::Application)
|
|
621
|
+
|
|
622
|
+
fixtures = config.root.join("test", "fixtures")
|
|
623
|
+
if fixtures_in_root_and_not_in_vendor?(fixtures)
|
|
624
|
+
ActiveSupport.on_load(:active_record_fixtures) { self.fixture_paths |= ["#{fixtures}/"] }
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
613
628
|
initializer :prepend_helpers_path do |app|
|
|
614
629
|
if !isolated? || (app == self)
|
|
615
630
|
app.config.helpers_paths.unshift(*paths["app/helpers"].existent)
|
|
@@ -713,6 +728,11 @@ module Rails
|
|
|
713
728
|
end
|
|
714
729
|
end
|
|
715
730
|
|
|
731
|
+
def fixtures_in_root_and_not_in_vendor?(fixtures)
|
|
732
|
+
fixtures.exist? && fixtures.to_s.start_with?(Rails.root.to_s) &&
|
|
733
|
+
!fixtures.to_s.start_with?(Rails.root.join("vendor").to_s)
|
|
734
|
+
end
|
|
735
|
+
|
|
716
736
|
def build_request(env)
|
|
717
737
|
env.merge!(env_config)
|
|
718
738
|
req = ActionDispatch::Request.new env
|
data/lib/rails/gem_version.rb
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Rails
|
|
4
|
-
# Returns the currently loaded version of Rails as a
|
|
4
|
+
# Returns the currently loaded version of \Rails as a +Gem::Version+.
|
|
5
5
|
def self.gem_version
|
|
6
6
|
Gem::Version.new VERSION::STRING
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
module VERSION
|
|
10
10
|
MAJOR = 7
|
|
11
|
-
MINOR =
|
|
12
|
-
TINY =
|
|
13
|
-
PRE =
|
|
11
|
+
MINOR = 1
|
|
12
|
+
TINY = 0
|
|
13
|
+
PRE = "beta1"
|
|
14
14
|
|
|
15
15
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
|
|
16
16
|
end
|
|
@@ -162,7 +162,7 @@ module Rails
|
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
-
# Adds configuration code to a Rails runtime environment.
|
|
165
|
+
# Adds configuration code to a \Rails runtime environment.
|
|
166
166
|
#
|
|
167
167
|
# By default, adds code inside the +Application+ class in
|
|
168
168
|
# +config/application.rb+ so that it applies to all environments.
|
|
@@ -349,7 +349,7 @@ module Rails
|
|
|
349
349
|
# ==== Options
|
|
350
350
|
#
|
|
351
351
|
# [+:env+]
|
|
352
|
-
# The Rails environment in which to run the task. Defaults to
|
|
352
|
+
# The \Rails environment in which to run the task. Defaults to
|
|
353
353
|
# <tt>ENV["RAILS_ENV"] || "development"</tt>.
|
|
354
354
|
#
|
|
355
355
|
# [+:abort_on_failure+]
|
|
@@ -365,7 +365,7 @@ module Rails
|
|
|
365
365
|
execute_command :rake, command, options
|
|
366
366
|
end
|
|
367
367
|
|
|
368
|
-
# Runs the specified Rails command.
|
|
368
|
+
# Runs the specified \Rails command.
|
|
369
369
|
#
|
|
370
370
|
# rails_command "db:migrate"
|
|
371
371
|
# rails_command "db:migrate", env: "production"
|
|
@@ -376,7 +376,7 @@ module Rails
|
|
|
376
376
|
# ==== Options
|
|
377
377
|
#
|
|
378
378
|
# [+:env+]
|
|
379
|
-
# The Rails environment in which to run the command. Defaults to
|
|
379
|
+
# The \Rails environment in which to run the command. Defaults to
|
|
380
380
|
# <tt>ENV["RAILS_ENV"] || "development"</tt>.
|
|
381
381
|
#
|
|
382
382
|
# [+:abort_on_failure+]
|
|
@@ -402,7 +402,7 @@ module Rails
|
|
|
402
402
|
end
|
|
403
403
|
end
|
|
404
404
|
|
|
405
|
-
# Make an entry in Rails routing file <tt>config/routes.rb</tt>
|
|
405
|
+
# Make an entry in \Rails routing file <tt>config/routes.rb</tt>
|
|
406
406
|
#
|
|
407
407
|
# route "root 'welcome#index'"
|
|
408
408
|
# route "root 'admin#index'", namespace: :admin
|
|
@@ -468,16 +468,7 @@ module Rails
|
|
|
468
468
|
abort_on_failure: options[:abort_on_failure],
|
|
469
469
|
}
|
|
470
470
|
|
|
471
|
-
in_root { run("#{sudo}#{
|
|
472
|
-
end
|
|
473
|
-
|
|
474
|
-
# Add an extension to the given name based on the platform.
|
|
475
|
-
def extify(name) # :doc:
|
|
476
|
-
if Gem.win_platform?
|
|
477
|
-
"#{name}.bat"
|
|
478
|
-
else
|
|
479
|
-
name
|
|
480
|
-
end
|
|
471
|
+
in_root { run("#{sudo}#{Shellwords.escape Gem.ruby} bin/#{executor} #{command}", config) }
|
|
481
472
|
end
|
|
482
473
|
|
|
483
474
|
# Always returns value in double quotes.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Rails
|
|
4
4
|
module Generators
|
|
5
|
-
# ActiveModel is a class to be implemented by each ORM to allow Rails to
|
|
5
|
+
# ActiveModel is a class to be implemented by each ORM to allow \Rails to
|
|
6
6
|
# generate customized controller code.
|
|
7
7
|
#
|
|
8
8
|
# The API has the same methods as ActiveRecord, but each method returns a
|
|
@@ -32,27 +32,21 @@ module Rails
|
|
|
32
32
|
@name = name
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# * GET +index+
|
|
35
|
+
# GET index
|
|
38
36
|
def self.all(klass)
|
|
39
37
|
"#{klass}.all"
|
|
40
38
|
end
|
|
41
39
|
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
# * PATCH / PUT +update+
|
|
47
|
-
# * DELETE +destroy+
|
|
40
|
+
# GET show
|
|
41
|
+
# GET edit
|
|
42
|
+
# PATCH/PUT update
|
|
43
|
+
# DELETE destroy
|
|
48
44
|
def self.find(klass, params = nil)
|
|
49
45
|
"#{klass}.find(#{params})"
|
|
50
46
|
end
|
|
51
47
|
|
|
52
|
-
#
|
|
53
|
-
#
|
|
54
|
-
# * GET +new+
|
|
55
|
-
# * POST +create+
|
|
48
|
+
# GET new
|
|
49
|
+
# POST create
|
|
56
50
|
def self.build(klass, params = nil)
|
|
57
51
|
if params
|
|
58
52
|
"#{klass}.new(#{params})"
|
|
@@ -61,33 +55,25 @@ module Rails
|
|
|
61
55
|
end
|
|
62
56
|
end
|
|
63
57
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
# * POST +create+
|
|
58
|
+
# POST create
|
|
67
59
|
def save
|
|
68
60
|
"#{name}.save"
|
|
69
61
|
end
|
|
70
62
|
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
# * PATCH / PUT +update+
|
|
63
|
+
# PATCH/PUT update
|
|
74
64
|
def update(params = nil)
|
|
75
65
|
"#{name}.update(#{params})"
|
|
76
66
|
end
|
|
77
67
|
|
|
78
|
-
#
|
|
79
|
-
#
|
|
80
|
-
# * POST +create+
|
|
81
|
-
# * PATCH / PUT +update+
|
|
68
|
+
# POST create
|
|
69
|
+
# PATCH/PUT update
|
|
82
70
|
def errors
|
|
83
71
|
"#{name}.errors"
|
|
84
72
|
end
|
|
85
73
|
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
# * DELETE +destroy+
|
|
74
|
+
# DELETE destroy
|
|
89
75
|
def destroy
|
|
90
|
-
"#{name}.destroy"
|
|
76
|
+
"#{name}.destroy!"
|
|
91
77
|
end
|
|
92
78
|
end
|
|
93
79
|
end
|