rails 2.2.3 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +272 -191
- data/MIT-LICENSE +1 -1
- data/README +6 -19
- data/Rakefile +24 -71
- data/bin/rails +1 -0
- data/builtin/rails_info/rails/info.rb +12 -8
- data/configs/databases/mysql.yml +3 -0
- data/configs/initializers/backtrace_silencers.rb +7 -0
- data/configs/initializers/new_rails_defaults.rb +2 -0
- data/configs/initializers/session_store.rb +15 -0
- data/dispatches/config.ru +7 -0
- data/doc/README_FOR_APP +2 -5
- data/environments/boot.rb +1 -0
- data/environments/environment.rb +14 -48
- data/environments/production.rb +11 -7
- data/environments/test.rb +6 -0
- data/helpers/application_controller.rb +10 -0
- data/helpers/test_helper.rb +1 -1
- data/html/500.html +0 -3
- data/html/index.html +1 -0
- data/lib/commands/about.rb +1 -1
- data/lib/commands/dbconsole.rb +18 -2
- data/lib/commands/plugin.rb +4 -3
- data/lib/commands/runner.rb +13 -7
- data/lib/commands/server.rb +98 -33
- data/lib/console_app.rb +4 -4
- data/lib/console_with_helpers.rb +2 -23
- data/lib/dispatcher.rb +1 -1
- data/lib/fcgi_handler.rb +12 -10
- data/lib/initializer.rb +108 -41
- data/lib/rails/backtrace_cleaner.rb +54 -0
- data/lib/rails/gem_dependency.rb +124 -94
- data/lib/rails/plugin.rb +49 -6
- data/lib/rails/plugin/loader.rb +66 -27
- data/lib/rails/plugin/locator.rb +1 -1
- data/lib/rails/rack.rb +3 -1
- data/lib/rails/rack/debugger.rb +21 -0
- data/lib/rails/rack/log_tailer.rb +35 -0
- data/lib/rails/rack/metal.rb +51 -0
- data/lib/rails/rack/static.rb +15 -4
- data/lib/rails/version.rb +2 -2
- data/lib/rails_generator/base.rb +3 -0
- data/lib/rails_generator/commands.rb +8 -3
- data/lib/rails_generator/generators/applications/app/app_generator.rb +210 -136
- data/lib/rails_generator/generators/applications/app/scm/git.rb +16 -0
- data/lib/rails_generator/generators/applications/app/scm/scm.rb +8 -0
- data/lib/rails_generator/generators/applications/app/scm/svn.rb +7 -0
- data/lib/rails_generator/generators/applications/app/template_runner.rb +401 -0
- data/lib/rails_generator/generators/components/controller/USAGE +12 -11
- data/lib/rails_generator/generators/components/controller/controller_generator.rb +7 -1
- data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/helper/USAGE +24 -0
- data/lib/rails_generator/generators/components/helper/helper_generator.rb +25 -0
- data/lib/rails_generator/generators/components/helper/templates/helper.rb +2 -0
- data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/metal/USAGE +8 -0
- data/lib/rails_generator/generators/components/metal/metal_generator.rb +8 -0
- data/lib/rails_generator/generators/components/metal/templates/metal.rb +12 -0
- data/lib/rails_generator/generators/components/resource/USAGE +2 -2
- data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -0
- data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +2 -0
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +4 -4
- data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +4 -0
- data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +2 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +1 -1
- data/lib/rails_generator/secret_key_generator.rb +2 -0
- data/lib/tasks/databases.rake +13 -6
- data/lib/tasks/documentation.rake +2 -9
- data/lib/tasks/framework.rake +26 -1
- data/lib/tasks/gems.rake +33 -48
- data/lib/tasks/middleware.rake +7 -0
- data/lib/tasks/misc.rake +7 -0
- data/lib/tasks/statistics.rake +0 -1
- data/lib/tasks/testing.rake +5 -5
- data/lib/tasks/tmp.rake +2 -2
- data/lib/test_help.rb +16 -8
- metadata +92 -159
- data/bin/performance/request +0 -3
- data/bin/process/inspector +0 -3
- data/bin/process/reaper +0 -3
- data/bin/process/spawner +0 -3
- data/config.ru +0 -17
- data/configs/apache.conf +0 -40
- data/configs/lighttpd.conf +0 -54
- data/doc/guides/html/2_2_release_notes.html +0 -1185
- data/doc/guides/html/actioncontroller_basics.html +0 -1270
- data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
- data/doc/guides/html/association_basics.html +0 -2585
- data/doc/guides/html/authors.html +0 -240
- data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
- data/doc/guides/html/caching_with_rails.html +0 -583
- data/doc/guides/html/command_line.html +0 -434
- data/doc/guides/html/configuring.html +0 -438
- data/doc/guides/html/creating_plugins.html +0 -1594
- data/doc/guides/html/debugging_rails_applications.html +0 -1175
- data/doc/guides/html/finders.html +0 -1090
- data/doc/guides/html/form_helpers.html +0 -638
- data/doc/guides/html/getting_started_with_rails.html +0 -2066
- data/doc/guides/html/index.html +0 -349
- data/doc/guides/html/layouts_and_rendering.html +0 -1406
- data/doc/guides/html/migrations.html +0 -921
- data/doc/guides/html/routing_outside_in.html +0 -2213
- data/doc/guides/html/security.html +0 -1346
- data/doc/guides/html/testing_rails_applications.html +0 -1859
- data/doc/guides/source/2_2_release_notes.txt +0 -435
- data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
- data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
- data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
- data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
- data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
- data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
- data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
- data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
- data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
- data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
- data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
- data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
- data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
- data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
- data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
- data/doc/guides/source/active_record_basics.txt +0 -181
- data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
- data/doc/guides/source/association_basics.txt +0 -1840
- data/doc/guides/source/authors.txt +0 -39
- data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
- data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
- data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
- data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
- data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
- data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
- data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
- data/doc/guides/source/caching_with_rails.txt +0 -367
- data/doc/guides/source/command_line.txt +0 -147
- data/doc/guides/source/configuring.txt +0 -225
- data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
- data/doc/guides/source/creating_plugins/appendix.txt +0 -46
- data/doc/guides/source/creating_plugins/controllers.txt +0 -59
- data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
- data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
- data/doc/guides/source/creating_plugins/gem.txt +0 -1
- data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
- data/doc/guides/source/creating_plugins/helpers.txt +0 -51
- data/doc/guides/source/creating_plugins/index.txt +0 -52
- data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
- data/doc/guides/source/creating_plugins/models.txt +0 -76
- data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
- data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
- data/doc/guides/source/debugging_rails_applications.txt +0 -733
- data/doc/guides/source/finders.txt +0 -668
- data/doc/guides/source/form_helpers.txt +0 -345
- data/doc/guides/source/getting_started_with_rails.txt +0 -1256
- data/doc/guides/source/images/belongs_to.png +0 -0
- data/doc/guides/source/images/bullet.gif +0 -0
- data/doc/guides/source/images/csrf.png +0 -0
- data/doc/guides/source/images/habtm.png +0 -0
- data/doc/guides/source/images/has_many.png +0 -0
- data/doc/guides/source/images/has_many_through.png +0 -0
- data/doc/guides/source/images/has_one.png +0 -0
- data/doc/guides/source/images/has_one_through.png +0 -0
- data/doc/guides/source/images/header_backdrop.png +0 -0
- data/doc/guides/source/images/icons/README +0 -5
- data/doc/guides/source/images/icons/callouts/1.png +0 -0
- data/doc/guides/source/images/icons/callouts/10.png +0 -0
- data/doc/guides/source/images/icons/callouts/11.png +0 -0
- data/doc/guides/source/images/icons/callouts/12.png +0 -0
- data/doc/guides/source/images/icons/callouts/13.png +0 -0
- data/doc/guides/source/images/icons/callouts/14.png +0 -0
- data/doc/guides/source/images/icons/callouts/15.png +0 -0
- data/doc/guides/source/images/icons/callouts/2.png +0 -0
- data/doc/guides/source/images/icons/callouts/3.png +0 -0
- data/doc/guides/source/images/icons/callouts/4.png +0 -0
- data/doc/guides/source/images/icons/callouts/5.png +0 -0
- data/doc/guides/source/images/icons/callouts/6.png +0 -0
- data/doc/guides/source/images/icons/callouts/7.png +0 -0
- data/doc/guides/source/images/icons/callouts/8.png +0 -0
- data/doc/guides/source/images/icons/callouts/9.png +0 -0
- data/doc/guides/source/images/icons/caution.png +0 -0
- data/doc/guides/source/images/icons/example.png +0 -0
- data/doc/guides/source/images/icons/home.png +0 -0
- data/doc/guides/source/images/icons/important.png +0 -0
- data/doc/guides/source/images/icons/next.png +0 -0
- data/doc/guides/source/images/icons/note.png +0 -0
- data/doc/guides/source/images/icons/prev.png +0 -0
- data/doc/guides/source/images/icons/tip.png +0 -0
- data/doc/guides/source/images/icons/up.png +0 -0
- data/doc/guides/source/images/icons/warning.png +0 -0
- data/doc/guides/source/images/polymorphic.png +0 -0
- data/doc/guides/source/images/rails_logo_remix.gif +0 -0
- data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
- data/doc/guides/source/images/session_fixation.png +0 -0
- data/doc/guides/source/index.txt +0 -118
- data/doc/guides/source/layouts_and_rendering.txt +0 -982
- data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
- data/doc/guides/source/migrations/changelog.txt +0 -5
- data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
- data/doc/guides/source/migrations/foreign_keys.txt +0 -8
- data/doc/guides/source/migrations/index.txt +0 -22
- data/doc/guides/source/migrations/rakeing_around.txt +0 -111
- data/doc/guides/source/migrations/scheming.txt +0 -47
- data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
- data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
- data/doc/guides/source/routing_outside_in.txt +0 -986
- data/doc/guides/source/security.txt +0 -984
- data/doc/guides/source/stylesheets/base.css +0 -358
- data/doc/guides/source/stylesheets/forms.css +0 -35
- data/doc/guides/source/stylesheets/more.css +0 -82
- data/doc/guides/source/templates/guides.html.erb +0 -97
- data/doc/guides/source/templates/inline.css +0 -165
- data/doc/guides/source/testing_rails_applications.txt +0 -995
- data/helpers/application.rb +0 -15
- data/lib/commands/performance/request.rb +0 -6
- data/lib/commands/process/inspector.rb +0 -68
- data/lib/commands/process/reaper.rb +0 -149
- data/lib/commands/process/spawner.rb +0 -219
- data/lib/commands/process/spinner.rb +0 -57
- data/lib/commands/servers/base.rb +0 -31
- data/lib/commands/servers/lighttpd.rb +0 -94
- data/lib/commands/servers/mongrel.rb +0 -69
- data/lib/commands/servers/new_mongrel.rb +0 -16
- data/lib/commands/servers/thin.rb +0 -25
- data/lib/commands/servers/webrick.rb +0 -66
- data/lib/rails/mongrel_server/commands.rb +0 -342
- data/lib/rails/mongrel_server/handler.rb +0 -55
- data/lib/rails/rack/logger.rb +0 -28
@@ -2,13 +2,14 @@ class ControllerGenerator < Rails::Generator::NamedBase
|
|
2
2
|
def manifest
|
3
3
|
record do |m|
|
4
4
|
# Check for class naming collisions.
|
5
|
-
m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
|
5
|
+
m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper", "#{class_name}HelperTest"
|
6
6
|
|
7
7
|
# Controller, helper, views, and test directories.
|
8
8
|
m.directory File.join('app/controllers', class_path)
|
9
9
|
m.directory File.join('app/helpers', class_path)
|
10
10
|
m.directory File.join('app/views', class_path, file_name)
|
11
11
|
m.directory File.join('test/functional', class_path)
|
12
|
+
m.directory File.join('test/unit/helpers', class_path)
|
12
13
|
|
13
14
|
# Controller class, functional test, and helper class.
|
14
15
|
m.template 'controller.rb',
|
@@ -26,6 +27,11 @@ class ControllerGenerator < Rails::Generator::NamedBase
|
|
26
27
|
class_path,
|
27
28
|
"#{file_name}_helper.rb")
|
28
29
|
|
30
|
+
m.template 'helper_test.rb',
|
31
|
+
File.join('test/unit/helpers',
|
32
|
+
class_path,
|
33
|
+
"#{file_name}_helper_test.rb")
|
34
|
+
|
29
35
|
# View template for each action.
|
30
36
|
actions.each do |action|
|
31
37
|
path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new helper. Pass the helper name, either
|
3
|
+
CamelCased or under_scored.
|
4
|
+
|
5
|
+
To create a helper within a module, specify the helper name as a
|
6
|
+
path like 'parent_module/helper_name'.
|
7
|
+
|
8
|
+
This generates a helper class in app/helpers and a helper test
|
9
|
+
suite in test/unit/helpers.
|
10
|
+
|
11
|
+
Example:
|
12
|
+
`./script/generate helper CreditCard`
|
13
|
+
|
14
|
+
Credit card helper.
|
15
|
+
Helper: app/helpers/credit_card_helper.rb
|
16
|
+
Test: test/unit/helpers/credit_card_helper_test.rb
|
17
|
+
|
18
|
+
Modules Example:
|
19
|
+
`./script/generate helper 'admin/credit_card'`
|
20
|
+
|
21
|
+
Credit card admin helper.
|
22
|
+
Helper: app/helpers/admin/credit_card_helper.rb
|
23
|
+
Test: test/unit/helpers/admin/credit_card_helper_test.rb
|
24
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class HelperGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
# Check for class naming collisions.
|
5
|
+
m.class_collisions class_path, "#{class_name}Helper", "#{class_name}HelperTest"
|
6
|
+
|
7
|
+
# Helper and helper test directories.
|
8
|
+
m.directory File.join('app/helpers', class_path)
|
9
|
+
m.directory File.join('test/unit/helpers', class_path)
|
10
|
+
|
11
|
+
# Helper and helper test class.
|
12
|
+
|
13
|
+
m.template 'helper.rb',
|
14
|
+
File.join('app/helpers',
|
15
|
+
class_path,
|
16
|
+
"#{file_name}_helper.rb")
|
17
|
+
|
18
|
+
m.template 'helper_test.rb',
|
19
|
+
File.join('test/unit/helpers',
|
20
|
+
class_path,
|
21
|
+
"#{file_name}_helper_test.rb")
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Allow the metal piece to run in isolation
|
2
|
+
require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
|
3
|
+
|
4
|
+
class <%= class_name %>
|
5
|
+
def self.call(env)
|
6
|
+
if env["PATH_INFO"] =~ /^\/<%= file_name %>/
|
7
|
+
[200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
|
8
|
+
else
|
9
|
+
[404, {"Content-Type" => "text/html"}, ["Not Found"]]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -11,8 +11,8 @@ Description:
|
|
11
11
|
You don't have to think up every attribute up front, but it helps to
|
12
12
|
sketch out a few so you can start working with the resource immediately.
|
13
13
|
|
14
|
-
This creates a model, controller, tests and fixtures for
|
15
|
-
corresponding map.resources declaration in config/routes.rb
|
14
|
+
This creates a model, controller, helper, tests and fixtures for all of them,
|
15
|
+
and the corresponding map.resources declaration in config/routes.rb
|
16
16
|
|
17
17
|
Unlike the scaffold generator, the resource generator does not create
|
18
18
|
views or add any methods to the generated controller.
|
@@ -40,6 +40,7 @@ class ResourceGenerator < Rails::Generator::NamedBase
|
|
40
40
|
m.directory(File.join('app/views', controller_class_path, controller_file_name))
|
41
41
|
m.directory(File.join('test/functional', controller_class_path))
|
42
42
|
m.directory(File.join('test/unit', class_path))
|
43
|
+
m.directory(File.join('test/unit/helpers', class_path))
|
43
44
|
|
44
45
|
m.dependency 'model', [name] + @args, :collision => :skip
|
45
46
|
|
@@ -49,6 +50,7 @@ class ResourceGenerator < Rails::Generator::NamedBase
|
|
49
50
|
|
50
51
|
m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
|
51
52
|
m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
|
53
|
+
m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
|
52
54
|
|
53
55
|
m.route_resources controller_file_name
|
54
56
|
end
|
@@ -47,6 +47,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
47
47
|
m.directory(File.join('app/views/layouts', controller_class_path))
|
48
48
|
m.directory(File.join('test/functional', controller_class_path))
|
49
49
|
m.directory(File.join('test/unit', class_path))
|
50
|
+
m.directory(File.join('test/unit/helpers', class_path))
|
50
51
|
m.directory(File.join('public/stylesheets', class_path))
|
51
52
|
|
52
53
|
for action in scaffold_views
|
@@ -66,6 +67,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
66
67
|
|
67
68
|
m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
|
68
69
|
m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
|
70
|
+
m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
|
69
71
|
|
70
72
|
m.route_resources controller_file_name
|
71
73
|
|
@@ -2,7 +2,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
2
2
|
# GET /<%= table_name %>
|
3
3
|
# GET /<%= table_name %>.xml
|
4
4
|
def index
|
5
|
-
@<%= table_name %> = <%= class_name %>.
|
5
|
+
@<%= table_name %> = <%= class_name %>.all
|
6
6
|
|
7
7
|
respond_to do |format|
|
8
8
|
format.html # index.html.erb
|
@@ -21,23 +21,23 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test "should show <%= file_name %>" do
|
24
|
-
get :show, :id => <%= table_name %>(:one).
|
24
|
+
get :show, :id => <%= table_name %>(:one).to_param
|
25
25
|
assert_response :success
|
26
26
|
end
|
27
27
|
|
28
28
|
test "should get edit" do
|
29
|
-
get :edit, :id => <%= table_name %>(:one).
|
29
|
+
get :edit, :id => <%= table_name %>(:one).to_param
|
30
30
|
assert_response :success
|
31
31
|
end
|
32
32
|
|
33
33
|
test "should update <%= file_name %>" do
|
34
|
-
put :update, :id => <%= table_name %>(:one).
|
34
|
+
put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
|
35
35
|
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
|
36
36
|
end
|
37
37
|
|
38
38
|
test "should destroy <%= file_name %>" do
|
39
39
|
assert_difference('<%= class_name %>.count', -1) do
|
40
|
-
delete :destroy, :id => <%= table_name %>(:one).
|
40
|
+
delete :destroy, :id => <%= table_name %>(:one).to_param
|
41
41
|
end
|
42
42
|
|
43
43
|
assert_redirected_to <%= table_name %>_path
|
@@ -10,9 +10,9 @@
|
|
10
10
|
</p>
|
11
11
|
<% end -%>
|
12
12
|
<p>
|
13
|
-
<%%= f.submit
|
13
|
+
<%%= f.submit 'Update' %>
|
14
14
|
</p>
|
15
15
|
<%% end %>
|
16
16
|
|
17
17
|
<%%= link_to 'Show', @<%= singular_name %> %> |
|
18
|
-
<%%= link_to 'Back', <%= plural_name %>_path %>
|
18
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% end -%>
|
8
8
|
</tr>
|
9
9
|
|
10
|
-
<%%
|
10
|
+
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
11
11
|
<tr>
|
12
12
|
<% for attribute in attributes -%>
|
13
13
|
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
@@ -21,4 +21,4 @@
|
|
21
21
|
|
22
22
|
<br />
|
23
23
|
|
24
|
-
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
24
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
data/lib/tasks/databases.rake
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
namespace :db do
|
2
|
+
task :load_config => :rails_env do
|
3
|
+
require 'active_record'
|
4
|
+
ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
|
5
|
+
end
|
6
|
+
|
2
7
|
namespace :create do
|
3
8
|
desc 'Create all the local databases defined in config/database.yml'
|
4
|
-
task :all => :
|
9
|
+
task :all => :load_config do
|
5
10
|
ActiveRecord::Base.configurations.each_value do |config|
|
6
11
|
# Skip entries that don't have a database key, such as the first entry here:
|
7
12
|
#
|
@@ -22,7 +27,7 @@ namespace :db do
|
|
22
27
|
end
|
23
28
|
|
24
29
|
desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
|
25
|
-
task :create => :
|
30
|
+
task :create => :load_config do
|
26
31
|
create_database(ActiveRecord::Base.configurations[RAILS_ENV])
|
27
32
|
end
|
28
33
|
|
@@ -76,7 +81,7 @@ namespace :db do
|
|
76
81
|
|
77
82
|
namespace :drop do
|
78
83
|
desc 'Drops all the local databases defined in config/database.yml'
|
79
|
-
task :all => :
|
84
|
+
task :all => :load_config do
|
80
85
|
ActiveRecord::Base.configurations.each_value do |config|
|
81
86
|
# Skip entries that don't have a database key
|
82
87
|
next unless config['database']
|
@@ -87,7 +92,7 @@ namespace :db do
|
|
87
92
|
end
|
88
93
|
|
89
94
|
desc 'Drops the database for the current RAILS_ENV'
|
90
|
-
task :drop => :
|
95
|
+
task :drop => :load_config do
|
91
96
|
config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
|
92
97
|
begin
|
93
98
|
drop_database(config)
|
@@ -105,7 +110,7 @@ namespace :db do
|
|
105
110
|
end
|
106
111
|
|
107
112
|
|
108
|
-
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
113
|
+
desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
109
114
|
task :migrate => :environment do
|
110
115
|
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
111
116
|
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
@@ -245,6 +250,7 @@ namespace :db do
|
|
245
250
|
File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
|
246
251
|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
247
252
|
end
|
253
|
+
Rake::Task["db:schema:dump"].reenable
|
248
254
|
end
|
249
255
|
|
250
256
|
desc "Load a schema.rb file into the database"
|
@@ -375,7 +381,7 @@ namespace :db do
|
|
375
381
|
end
|
376
382
|
|
377
383
|
namespace :sessions do
|
378
|
-
desc "Creates a sessions migration for use with
|
384
|
+
desc "Creates a sessions migration for use with ActiveRecord::SessionStore"
|
379
385
|
task :create => :environment do
|
380
386
|
raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
|
381
387
|
require 'rails_generator'
|
@@ -393,6 +399,7 @@ end
|
|
393
399
|
def drop_database(config)
|
394
400
|
case config['adapter']
|
395
401
|
when 'mysql'
|
402
|
+
ActiveRecord::Base.establish_connection(config)
|
396
403
|
ActiveRecord::Base.connection.drop_database config['database']
|
397
404
|
when /^sqlite/
|
398
405
|
FileUtils.rm(File.join(RAILS_ROOT, config['database']))
|
@@ -54,15 +54,8 @@ namespace :doc do
|
|
54
54
|
|
55
55
|
desc "Generate Rails guides"
|
56
56
|
task :guides do
|
57
|
-
|
58
|
-
|
59
|
-
FileUtils.rm_r(destination) if File.directory?(destination)
|
60
|
-
FileUtils.mkdir(destination)
|
61
|
-
|
62
|
-
FileUtils.cp_r File.join(source, 'html/.'), File.join(destination)
|
63
|
-
# Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
|
64
|
-
FileUtils.cp_r File.join(source, 'source/images'), File.join(destination)
|
65
|
-
FileUtils.cp_r File.join(source, 'source/stylesheets'), File.join(destination, 'stylesheets')
|
57
|
+
require File.join(RAILTIES_PATH, "guides/rails_guides")
|
58
|
+
RailsGuides::Generator.new(File.join(RAILS_ROOT, "doc/guides")).generate
|
66
59
|
end
|
67
60
|
|
68
61
|
namespace :plugins do
|
data/lib/tasks/framework.rake
CHANGED
@@ -78,7 +78,13 @@ namespace :rails do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
desc "Update both configs, scripts and public/javascripts from Rails"
|
81
|
-
task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
|
81
|
+
task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
|
82
|
+
|
83
|
+
desc "Applies the template supplied by LOCATION=/path/to/template"
|
84
|
+
task :template do
|
85
|
+
require 'rails_generator/generators/applications/app/template_runner'
|
86
|
+
Rails::TemplateRunner.new(ENV["LOCATION"])
|
87
|
+
end
|
82
88
|
|
83
89
|
namespace :update do
|
84
90
|
desc "Add new scripts to the application script/ directory"
|
@@ -114,5 +120,24 @@ namespace :rails do
|
|
114
120
|
require 'railties_path'
|
115
121
|
FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
|
116
122
|
end
|
123
|
+
|
124
|
+
desc "Rename application.rb to application_controller.rb"
|
125
|
+
task :application_controller do
|
126
|
+
old_style = RAILS_ROOT + '/app/controllers/application.rb'
|
127
|
+
new_style = RAILS_ROOT + '/app/controllers/application_controller.rb'
|
128
|
+
if File.exists?(old_style) && !File.exists?(new_style)
|
129
|
+
FileUtils.mv(old_style, new_style)
|
130
|
+
puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc "Generate dispatcher files in RAILS_ROOT/public"
|
135
|
+
task :generate_dispatchers do
|
136
|
+
require 'railties_path'
|
137
|
+
FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru')
|
138
|
+
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi')
|
139
|
+
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb')
|
140
|
+
FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi')
|
141
|
+
end
|
117
142
|
end
|
118
143
|
end
|
data/lib/tasks/gems.rake
CHANGED
@@ -9,72 +9,57 @@ task :gems => 'gems:base' do
|
|
9
9
|
puts "R = Framework (loaded before rails starts)"
|
10
10
|
end
|
11
11
|
|
12
|
-
def print_gem_status(gem, indent=1)
|
13
|
-
code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
|
14
|
-
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
|
15
|
-
gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
|
16
|
-
end
|
17
|
-
|
18
12
|
namespace :gems do
|
19
13
|
task :base do
|
20
|
-
$
|
14
|
+
$gems_rake_task = true
|
15
|
+
require 'rubygems'
|
16
|
+
require 'rubygems/gem_runner'
|
21
17
|
Rake::Task[:environment].invoke
|
22
18
|
end
|
23
19
|
|
24
20
|
desc "Build any native extensions for unpacked gems"
|
25
21
|
task :build do
|
26
|
-
$
|
27
|
-
|
28
|
-
|
29
|
-
spec_file = File.join(gem_dir, '.specification')
|
30
|
-
next unless File.exists?(spec_file)
|
31
|
-
specification = YAML::load_file(spec_file)
|
32
|
-
next unless ENV['GEM'].blank? || ENV['GEM'] == specification.name
|
33
|
-
Rails::GemBuilder.new(specification, gem_dir).build_extensions
|
34
|
-
puts "Built gem: '#{gem_dir}'"
|
35
|
-
end
|
22
|
+
$gems_build_rake_task = true
|
23
|
+
Rake::Task['gems:unpack'].invoke
|
24
|
+
current_gems.each &:build
|
36
25
|
end
|
37
26
|
|
38
|
-
desc "Installs all required gems
|
27
|
+
desc "Installs all required gems."
|
39
28
|
task :install => :base do
|
40
|
-
|
41
|
-
require 'rubygems/gem_runner'
|
42
|
-
Rails.configuration.gems.each { |gem| gem.install unless gem.loaded? }
|
29
|
+
current_gems.each &:install
|
43
30
|
end
|
44
31
|
|
45
|
-
desc "Unpacks
|
46
|
-
task :unpack => :
|
47
|
-
|
48
|
-
require 'rubygems/gem_runner'
|
49
|
-
Rails.configuration.gems.each do |gem|
|
50
|
-
next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
51
|
-
gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
|
52
|
-
end
|
32
|
+
desc "Unpacks all required gems into vendor/gems."
|
33
|
+
task :unpack => :install do
|
34
|
+
current_gems.each &:unpack
|
53
35
|
end
|
54
36
|
|
55
37
|
namespace :unpack do
|
56
|
-
desc "Unpacks
|
57
|
-
task :dependencies => :
|
58
|
-
|
59
|
-
require 'rubygems/gem_runner'
|
60
|
-
Rails.configuration.gems.each do |gem|
|
61
|
-
next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
|
62
|
-
gem.dependencies.each do |dependency|
|
63
|
-
next if dependency.frozen?
|
64
|
-
dependency.unpack_to(Rails::GemDependency.unpacked_path)
|
65
|
-
end
|
66
|
-
end
|
38
|
+
desc "Unpacks all required gems and their dependencies into vendor/gems."
|
39
|
+
task :dependencies => :install do
|
40
|
+
current_gems.each { |gem| gem.unpack(:recursive => true) }
|
67
41
|
end
|
68
42
|
end
|
69
43
|
|
70
44
|
desc "Regenerate gem specifications in correct format."
|
71
45
|
task :refresh_specs => :base do
|
72
|
-
|
73
|
-
require 'rubygems/gem_runner'
|
74
|
-
Rails::VendorGemSourceIndex.silence_spec_warnings = true
|
75
|
-
Rails.configuration.gems.each do |gem|
|
76
|
-
next unless gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
|
77
|
-
gem.refresh_spec(Rails::GemDependency.unpacked_path) if gem.loaded?
|
78
|
-
end
|
46
|
+
current_gems.each &:refresh
|
79
47
|
end
|
80
|
-
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def current_gems
|
51
|
+
gems = Rails.configuration.gems
|
52
|
+
gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank?
|
53
|
+
gems
|
54
|
+
end
|
55
|
+
|
56
|
+
def print_gem_status(gem, indent=1)
|
57
|
+
code = case
|
58
|
+
when gem.framework_gem? then 'R'
|
59
|
+
when gem.frozen? then 'F'
|
60
|
+
when gem.installed? then 'I'
|
61
|
+
else ' '
|
62
|
+
end
|
63
|
+
puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
|
64
|
+
gem.dependencies.each { |g| print_gem_status(g, indent+1) }
|
65
|
+
end
|