railties 3.0.0.beta → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -1
- data/README +9 -9
- data/bin/rails +28 -9
- data/guides/images/challenge.png +0 -0
- data/guides/images/edge_badge.png +0 -0
- data/guides/images/posts_index.png +0 -0
- data/guides/images/rails_welcome.png +0 -0
- data/guides/rails_guides.rb +9 -22
- data/guides/rails_guides/generator.rb +79 -50
- data/guides/rails_guides/textile_extensions.rb +3 -3
- data/guides/source/2_2_release_notes.textile +1 -1
- data/guides/source/2_3_release_notes.textile +1 -1
- data/guides/source/3_0_release_notes.textile +46 -38
- data/guides/source/action_controller_overview.textile +2 -2
- data/guides/source/action_mailer_basics.textile +4 -4
- data/guides/source/action_view_overview.textile +2 -2
- data/guides/source/active_record_querying.textile +73 -95
- data/guides/source/active_support_core_extensions.textile +993 -85
- data/guides/source/activerecord_validations_callbacks.textile +3 -3
- data/guides/source/caching_with_rails.textile +1 -1
- data/guides/source/command_line.textile +90 -88
- data/guides/source/configuring.textile +10 -10
- data/guides/source/contribute.textile +2 -2
- data/guides/source/contributing_to_rails.textile +14 -7
- data/guides/source/credits.textile.erb +8 -0
- data/guides/source/debugging_rails_applications.textile +6 -6
- data/guides/source/form_helpers.textile +1 -1
- data/guides/source/generators.textile +14 -14
- data/guides/source/getting_started.textile +634 -500
- data/guides/source/index.textile.erb +16 -1
- data/guides/source/layout.html.erb +7 -1
- data/guides/source/layouts_and_rendering.textile +299 -71
- data/guides/source/migrations.textile +5 -5
- data/guides/source/performance_testing.textile +8 -8
- data/guides/source/plugins.textile +26 -24
- data/guides/source/rails_on_rack.textile +5 -5
- data/guides/source/routing.textile +119 -117
- data/guides/source/security.textile +1 -1
- data/guides/source/testing.textile +4 -4
- data/lib/rails.rb +4 -1
- data/lib/rails/application.rb +44 -7
- data/lib/rails/application/bootstrap.rb +2 -14
- data/lib/rails/application/configuration.rb +69 -5
- data/lib/rails/application/finisher.rb +2 -3
- data/lib/rails/application/metal_loader.rb +1 -1
- data/lib/rails/application/routes_reloader.rb +1 -1
- data/lib/rails/backtrace_cleaner.rb +0 -11
- data/lib/rails/commands.rb +7 -6
- data/lib/rails/commands/application.rb +1 -1
- data/lib/rails/commands/console.rb +1 -1
- data/lib/rails/commands/dbconsole.rb +12 -0
- data/lib/rails/commands/destroy.rb +2 -2
- data/lib/rails/commands/generate.rb +2 -2
- data/lib/rails/commands/performance/benchmarker.rb +2 -2
- data/lib/rails/commands/performance/profiler.rb +2 -2
- data/lib/rails/commands/plugin.rb +6 -6
- data/lib/rails/commands/runner.rb +2 -0
- data/lib/rails/commands/server.rb +23 -8
- data/lib/rails/configuration.rb +2 -84
- data/lib/rails/console/app.rb +4 -3
- data/lib/rails/console/helpers.rb +3 -1
- data/lib/rails/engine.rb +107 -12
- data/lib/rails/engine/configuration.rb +8 -2
- data/lib/rails/generators.rb +22 -7
- data/lib/rails/generators/actions.rb +16 -6
- data/lib/rails/generators/base.rb +15 -8
- data/lib/rails/generators/erb.rb +21 -0
- data/lib/{generators → rails/generators}/erb/controller/controller_generator.rb +4 -5
- data/lib/{generators → rails/generators}/erb/controller/templates/view.html.erb +0 -0
- data/lib/rails/generators/erb/mailer/mailer_generator.rb +13 -0
- data/lib/{generators → rails/generators}/erb/mailer/templates/view.text.erb +0 -0
- data/lib/{generators → rails/generators}/erb/scaffold/scaffold_generator.rb +14 -26
- data/lib/{generators → rails/generators}/erb/scaffold/templates/_form.html.erb +1 -1
- data/lib/{generators → rails/generators}/erb/scaffold/templates/edit.html.erb +0 -0
- data/lib/{generators → rails/generators}/erb/scaffold/templates/index.html.erb +1 -1
- data/lib/{generators → rails/generators}/erb/scaffold/templates/layout.html.erb +1 -0
- data/lib/{generators → rails/generators}/erb/scaffold/templates/new.html.erb +0 -0
- data/lib/{generators → rails/generators}/erb/scaffold/templates/show.html.erb +0 -0
- data/lib/rails/generators/named_base.rb +4 -0
- data/lib/{generators → rails/generators}/rails/app/USAGE +0 -0
- data/lib/{generators → rails/generators}/rails/app/app_generator.rb +21 -7
- data/lib/rails/generators/rails/app/templates/Gemfile +34 -0
- data/lib/{generators → rails/generators}/rails/app/templates/README +9 -8
- data/lib/{generators → rails/generators}/rails/app/templates/Rakefile +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/app/controllers/application_controller.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/app/helpers/application_helper.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/app/views/layouts/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config.ru +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/application.rb +4 -3
- data/lib/rails/generators/rails/app/templates/config/boot.rb +14 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/frontbase.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/ibm_db.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/mysql.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/oracle.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/postgresql.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/databases/sqlite3.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/environment.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/environments/development.rb.tt +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/environments/production.rb.tt +9 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/environments/test.rb.tt +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/initializers/backtrace_silencers.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/initializers/cookie_verification_secret.rb.tt +1 -1
- data/lib/{generators → rails/generators}/rails/app/templates/config/initializers/inflections.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/initializers/mime_types.rb +0 -0
- data/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt +10 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/locales/en.yml +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/config/routes.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/db/seeds.rb +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/doc/README_FOR_APP +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/gitignore +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/404.html +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/422.html +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/500.html +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/favicon.ico +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/images/rails.png +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/index.html +17 -17
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/application.js +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/controls.js +5 -3
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/dragdrop.js +7 -6
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/effects.js +8 -13
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/prototype.js +1573 -1019
- data/lib/{generators → rails/generators}/rails/app/templates/public/javascripts/rails.js +1 -2
- data/lib/{generators → rails/generators}/rails/app/templates/public/robots.txt +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/script/rails +0 -1
- data/lib/{generators → rails/generators}/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/app/templates/test/performance/browsing_test.rb +1 -1
- data/lib/{generators → rails/generators}/rails/app/templates/test/test_helper.rb +1 -1
- data/lib/{generators → rails/generators}/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/controller/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/controller/controller_generator.rb +6 -0
- data/lib/{generators → rails/generators}/rails/controller/templates/controller.rb +0 -0
- data/lib/{generators → rails/generators}/rails/generator/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/generator/generator_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/generator/templates/%file_name%_generator.rb.tt +0 -0
- data/lib/{generators → rails/generators}/rails/generator/templates/USAGE.tt +1 -1
- data/lib/{generators → rails/generators}/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/{generators → rails/generators}/rails/helper/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/helper/helper_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/helper/templates/helper.rb +0 -0
- data/lib/{generators → rails/generators}/rails/integration_test/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/integration_test/integration_test_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/mailer/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/mailer/mailer_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/mailer/templates/mailer.rb +0 -0
- data/lib/{generators → rails/generators}/rails/metal/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/metal/metal_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/metal/templates/metal.rb +0 -0
- data/lib/{generators → rails/generators}/rails/migration/USAGE +2 -2
- data/lib/{generators → rails/generators}/rails/migration/migration_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/model/USAGE +2 -2
- data/lib/{generators → rails/generators}/rails/model/model_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/observer/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/observer/observer_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/performance_test/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/performance_test/performance_test_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/plugin/plugin_generator.rb +1 -1
- data/lib/{generators → rails/generators}/rails/plugin/templates/MIT-LICENSE.tt +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/README.tt +0 -0
- data/lib/rails/generators/rails/plugin/templates/Rakefile.tt +23 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/init.rb +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/install.rb +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/lib/%file_name%.rb.tt +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +0 -0
- data/lib/{generators → rails/generators}/rails/plugin/templates/uninstall.rb +0 -0
- data/lib/{generators → rails/generators}/rails/resource/USAGE +3 -3
- data/lib/{generators → rails/generators}/rails/resource/resource_generator.rb +3 -1
- data/lib/{generators → rails/generators}/rails/scaffold/USAGE +4 -4
- data/lib/{generators → rails/generators}/rails/scaffold/scaffold_generator.rb +1 -1
- data/lib/{generators → rails/generators}/rails/scaffold_controller/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/scaffold_controller/scaffold_controller_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/scaffold_controller/templates/controller.rb +2 -2
- data/lib/{generators → rails/generators}/rails/session_migration/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/session_migration/session_migration_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/stylesheets/USAGE +1 -1
- data/lib/{generators → rails/generators}/rails/stylesheets/stylesheets_generator.rb +0 -0
- data/lib/{generators → rails/generators}/rails/stylesheets/templates/scaffold.css +4 -0
- data/lib/{generators → rails/generators}/test_unit.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/controller/controller_generator.rb +2 -1
- data/lib/rails/generators/test_unit/controller/templates/functional_test.rb +18 -0
- data/lib/{generators → rails/generators}/test_unit/helper/helper_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/helper/templates/helper_test.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/integration/integration_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/integration/templates/integration_test.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/mailer/mailer_generator.rb +1 -8
- data/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +20 -0
- data/lib/{generators → rails/generators}/test_unit/model/model_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/model/templates/fixtures.yml +0 -0
- data/lib/{generators → rails/generators}/test_unit/model/templates/unit_test.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/observer/observer_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/observer/templates/unit_test.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/performance/performance_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/performance/templates/performance_test.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/plugin/plugin_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/plugin/templates/%file_name%_test.rb.tt +0 -0
- data/lib/{generators → rails/generators}/test_unit/plugin/templates/test_helper.rb +0 -0
- data/lib/{generators → rails/generators}/test_unit/scaffold/scaffold_generator.rb +1 -1
- data/lib/{generators → rails/generators}/test_unit/scaffold/templates/functional_test.rb +9 -5
- data/{builtin/rails_info → lib}/rails/info.rb +0 -0
- data/{builtin/rails_info → lib}/rails/info_controller.rb +0 -0
- data/{builtin/routes.rb → lib/rails/info_routes.rb} +2 -2
- data/lib/rails/{subscriber.rb → log_subscriber.rb} +27 -27
- data/lib/rails/{subscriber → log_subscriber}/test_helper.rb +15 -16
- data/lib/rails/plugin.rb +31 -8
- data/lib/rails/rack/debugger.rb +3 -1
- data/lib/rails/rack/logger.rb +4 -4
- data/lib/rails/railtie.rb +179 -16
- data/lib/rails/railtie/configuration.rb +56 -1
- data/lib/rails/tasks/documentation.rake +38 -20
- data/lib/rails/tasks/framework.rake +16 -9
- data/lib/rails/tasks/misc.rake +3 -5
- data/lib/rails/tasks/routes.rake +2 -2
- data/lib/rails/test_help.rb +21 -1
- data/lib/rails/test_unit/railtie.rb +1 -3
- data/lib/rails/version.rb +3 -2
- metadata +199 -171
- data/builtin/rails_info/rails/info_helper.rb +0 -2
- data/lib/generators/erb.rb +0 -8
- data/lib/generators/erb/mailer/mailer_generator.rb +0 -20
- data/lib/generators/rails/app/templates/Gemfile +0 -34
- data/lib/generators/rails/app/templates/config/boot.rb +0 -17
- data/lib/generators/rails/app/templates/config/initializers/session_store.rb.tt +0 -15
- data/lib/generators/rails/model_subclass/model_subclass_generator.rb +0 -12
- data/lib/generators/rails/plugin/templates/Rakefile.tt +0 -10
- data/lib/generators/test_unit/controller/templates/functional_test.rb +0 -8
- data/lib/generators/test_unit/mailer/templates/fixture +0 -3
- data/lib/generators/test_unit/mailer/templates/functional_test.rb +0 -22
- data/lib/rails/railties_path.rb +0 -1
@@ -32,7 +32,7 @@ module Rails
|
|
32
32
|
options[:git] = "-b #{options[:branch]} #{options[:git]}" if options[:branch]
|
33
33
|
options[:svn] = "-r #{options[:revision]} #{options[:svn]}" if options[:revision]
|
34
34
|
in_root do
|
35
|
-
run_ruby_script "script/plugin install #{options[:svn] || options[:git]}", :verbose => false
|
35
|
+
run_ruby_script "script/rails plugin install #{options[:svn] || options[:git]}", :verbose => false
|
36
36
|
end
|
37
37
|
else
|
38
38
|
log "! no git or svn provided for #{name}. Skipping..."
|
@@ -69,7 +69,7 @@ module Rails
|
|
69
69
|
# otherwise use name (version).
|
70
70
|
parts, message = [ name.inspect ], name
|
71
71
|
if version ||= options.delete(:version)
|
72
|
-
parts << version
|
72
|
+
parts << version.inspect
|
73
73
|
message << " (#{version})"
|
74
74
|
end
|
75
75
|
message = options[:git] if options[:git]
|
@@ -81,7 +81,7 @@ module Rails
|
|
81
81
|
end
|
82
82
|
|
83
83
|
in_root do
|
84
|
-
append_file "Gemfile", "gem #{parts.join(", ")}", :verbose => false
|
84
|
+
append_file "Gemfile", "gem #{parts.join(", ")}\n", :verbose => false
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
@@ -89,12 +89,12 @@ module Rails
|
|
89
89
|
#
|
90
90
|
# ==== Example
|
91
91
|
#
|
92
|
-
#
|
92
|
+
# add_source "http://gems.github.com/"
|
93
93
|
def add_source(source, options={})
|
94
94
|
log :source, source
|
95
95
|
|
96
96
|
in_root do
|
97
|
-
prepend_file "Gemfile", "source #{source.inspect}", :verbose => false
|
97
|
+
prepend_file "Gemfile", "source #{source.inspect}\n", :verbose => false
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -226,7 +226,7 @@ module Rails
|
|
226
226
|
log :generate, what
|
227
227
|
argument = args.map {|arg| arg.to_s }.flatten.join(" ")
|
228
228
|
|
229
|
-
in_root { run_ruby_script("script/generate #{what} #{argument}", :verbose => false) }
|
229
|
+
in_root { run_ruby_script("script/rails generate #{what} #{argument}", :verbose => false) }
|
230
230
|
end
|
231
231
|
|
232
232
|
# Runs the supplied rake task
|
@@ -280,6 +280,16 @@ module Rails
|
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
283
|
+
# Reads the given file at the source root and prints it in the console.
|
284
|
+
#
|
285
|
+
# === Example
|
286
|
+
#
|
287
|
+
# readme "README"
|
288
|
+
#
|
289
|
+
def readme(path)
|
290
|
+
say File.read(find_in_source_paths(path))
|
291
|
+
end
|
292
|
+
|
283
293
|
protected
|
284
294
|
|
285
295
|
# Define log for backwards compatibility. If just one argument is sent,
|
@@ -1,4 +1,12 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'thor/group'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Thor is not available.\nIf you ran this command from a git checkout " \
|
5
|
+
"of Rails, please make sure thor is installed,\nand run this command " \
|
6
|
+
"as `ruby /path/to/rails myapp --dev`"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
2
10
|
require 'rails/generators/actions'
|
3
11
|
|
4
12
|
module Rails
|
@@ -17,7 +25,7 @@ module Rails
|
|
17
25
|
def self.source_root
|
18
26
|
@_rails_source_root ||= begin
|
19
27
|
if base_name && generator_name
|
20
|
-
File.expand_path(File.join(
|
28
|
+
File.expand_path(File.join(base_name, generator_name, 'templates'), File.dirname(__FILE__))
|
21
29
|
end
|
22
30
|
end
|
23
31
|
end
|
@@ -62,7 +70,7 @@ module Rails
|
|
62
70
|
#
|
63
71
|
# For example, if the user invoke the controller generator as:
|
64
72
|
#
|
65
|
-
#
|
73
|
+
# rails generate controller Account --test-framework=test_unit
|
66
74
|
#
|
67
75
|
# The controller generator will then try to invoke the following generators:
|
68
76
|
#
|
@@ -117,11 +125,11 @@ module Rails
|
|
117
125
|
# All hooks come with switches for user interface. If the user don't want
|
118
126
|
# to use any test framework, he can do:
|
119
127
|
#
|
120
|
-
#
|
128
|
+
# rails generate controller Account --skip-test-framework
|
121
129
|
#
|
122
130
|
# Or similarly:
|
123
131
|
#
|
124
|
-
#
|
132
|
+
# rails generate controller Account --no-test-framework
|
125
133
|
#
|
126
134
|
# ==== Boolean hooks
|
127
135
|
#
|
@@ -133,7 +141,7 @@ module Rails
|
|
133
141
|
#
|
134
142
|
# Then, if you want, webrat to be invoked, just supply:
|
135
143
|
#
|
136
|
-
#
|
144
|
+
# rails generate controller Account --webrat
|
137
145
|
#
|
138
146
|
# The hooks lookup is similar as above:
|
139
147
|
#
|
@@ -213,8 +221,7 @@ module Rails
|
|
213
221
|
if base.name && base.name !~ /Base$/
|
214
222
|
Rails::Generators.subclasses << base
|
215
223
|
|
216
|
-
|
217
|
-
path = File.expand_path(File.join(Rails.root, 'lib', 'templates'))
|
224
|
+
Rails::Generators.templates_path.each do |path|
|
218
225
|
if base.name.include?('::')
|
219
226
|
base.source_paths << File.join(path, base.base_name, base.generator_name)
|
220
227
|
else
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
|
3
|
+
module Erb
|
4
|
+
module Generators
|
5
|
+
class Base < Rails::Generators::NamedBase #:nodoc:
|
6
|
+
protected
|
7
|
+
|
8
|
+
def format
|
9
|
+
:html
|
10
|
+
end
|
11
|
+
|
12
|
+
def handler
|
13
|
+
:erb
|
14
|
+
end
|
15
|
+
|
16
|
+
def filename_with_extensions(name)
|
17
|
+
[name, format, handler].compact.join(".")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
require 'generators/erb'
|
1
|
+
require 'rails/generators/erb'
|
2
2
|
|
3
3
|
module Erb
|
4
4
|
module Generators
|
5
5
|
class ControllerGenerator < Base
|
6
6
|
argument :actions, :type => :array, :default => [], :banner => "action action"
|
7
7
|
|
8
|
-
def
|
8
|
+
def copy_view_files
|
9
9
|
base_path = File.join("app/views", class_path, file_name)
|
10
10
|
empty_directory base_path
|
11
11
|
|
12
12
|
actions.each do |action|
|
13
13
|
@action = action
|
14
|
-
@path
|
15
|
-
|
16
|
-
template 'view.html.erb', @path
|
14
|
+
@path = File.join(base_path, filename_with_extensions(action))
|
15
|
+
template filename_with_extensions(:view), @path
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'generators/erb'
|
1
|
+
require 'rails/generators/erb'
|
2
2
|
require 'rails/generators/resource_helpers'
|
3
3
|
|
4
4
|
module Erb
|
@@ -15,39 +15,27 @@ module Erb
|
|
15
15
|
empty_directory File.join("app/views", controller_file_path)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
def copy_edit_file
|
24
|
-
copy_view :edit
|
25
|
-
end
|
18
|
+
def copy_view_files
|
19
|
+
views = available_views
|
20
|
+
views.delete("index") if options[:singleton]
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
def copy_new_file
|
32
|
-
copy_view :new
|
33
|
-
end
|
34
|
-
|
35
|
-
def copy_form_file
|
36
|
-
copy_view :_form
|
22
|
+
views.each do |view|
|
23
|
+
filename = filename_with_extensions(view)
|
24
|
+
template filename, File.join("app/views", controller_file_path, filename)
|
25
|
+
end
|
37
26
|
end
|
38
27
|
|
39
28
|
def copy_layout_file
|
40
29
|
return unless options[:layout]
|
41
|
-
template
|
42
|
-
|
30
|
+
template filename_with_extensions(:layout),
|
31
|
+
File.join("app/views/layouts", controller_class_path, filename_with_extensions(controller_file_name))
|
43
32
|
end
|
44
33
|
|
45
|
-
|
46
|
-
|
47
|
-
def copy_view(view)
|
48
|
-
template "#{view}.html.erb", File.join("app/views", controller_file_path, "#{view}.html.erb")
|
49
|
-
end
|
34
|
+
protected
|
50
35
|
|
36
|
+
def available_views
|
37
|
+
%w(index edit show new _form)
|
38
|
+
end
|
51
39
|
end
|
52
40
|
end
|
53
41
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -5,7 +5,11 @@ require 'rails/version' unless defined?(Rails::VERSION)
|
|
5
5
|
module Rails::Generators
|
6
6
|
# We need to store the RAILS_DEV_PATH in a constant, otherwise the path
|
7
7
|
# can change in Ruby 1.8.7 when we FileUtils.cd.
|
8
|
-
RAILS_DEV_PATH = File.expand_path("
|
8
|
+
RAILS_DEV_PATH = File.expand_path("../../../../../..", File.dirname(__FILE__))
|
9
|
+
|
10
|
+
RESERVED_NAMES = %w[generate console server dbconsole
|
11
|
+
application destroy benchmarker profiler
|
12
|
+
plugin runner test]
|
9
13
|
|
10
14
|
class AppGenerator < Base
|
11
15
|
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
@@ -27,6 +31,9 @@ module Rails::Generators
|
|
27
31
|
class_option :edge, :type => :boolean, :default => false,
|
28
32
|
:desc => "Setup the application with Gemfile pointing to Rails repository"
|
29
33
|
|
34
|
+
class_option :skip_gemfile, :type => :boolean, :default => false,
|
35
|
+
:desc => "Don't create a Gemfile"
|
36
|
+
|
30
37
|
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
|
31
38
|
:desc => "Skip ActiveRecord files"
|
32
39
|
|
@@ -67,7 +74,7 @@ module Rails::Generators
|
|
67
74
|
copy_file "gitignore", ".gitignore" unless options[:skip_git]
|
68
75
|
template "Rakefile"
|
69
76
|
template "config.ru"
|
70
|
-
template "Gemfile"
|
77
|
+
template "Gemfile" unless options[:skip_gemfile]
|
71
78
|
end
|
72
79
|
|
73
80
|
def create_app_files
|
@@ -134,8 +141,11 @@ module Rails::Generators
|
|
134
141
|
end
|
135
142
|
|
136
143
|
def create_prototype_files
|
137
|
-
|
138
|
-
|
144
|
+
unless options[:skip_prototype]
|
145
|
+
directory "public/javascripts"
|
146
|
+
else
|
147
|
+
empty_directory_with_gitkeep "public/javascripts"
|
148
|
+
end
|
139
149
|
end
|
140
150
|
|
141
151
|
def create_script_files
|
@@ -171,7 +181,8 @@ module Rails::Generators
|
|
171
181
|
end
|
172
182
|
|
173
183
|
def bundle_if_dev_or_edge
|
174
|
-
|
184
|
+
bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
|
185
|
+
run "#{bundle_command} install" if dev_or_edge?
|
175
186
|
end
|
176
187
|
|
177
188
|
protected
|
@@ -209,9 +220,12 @@ module Rails::Generators
|
|
209
220
|
end
|
210
221
|
|
211
222
|
def valid_app_const?
|
212
|
-
|
213
|
-
when /^\d/
|
223
|
+
if app_const =~ /^\d/
|
214
224
|
raise Error, "Invalid application name #{app_name}. Please give a name which does not start with numbers."
|
225
|
+
elsif RESERVED_NAMES.include?(app_name)
|
226
|
+
raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
|
227
|
+
elsif Object.const_defined?(app_const_base)
|
228
|
+
raise Error, "Invalid application name #{app_name}, constant #{app_const_base} is already in use. Please choose another application name."
|
215
229
|
end
|
216
230
|
end
|
217
231
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
<%- if options.dev? -%>
|
4
|
+
gem 'rails', :path => '<%= Rails::Generators::RAILS_DEV_PATH %>'
|
5
|
+
<%- elsif options.edge? -%>
|
6
|
+
gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
+
<%- else -%>
|
8
|
+
gem 'rails', '<%= Rails::VERSION::STRING %>'
|
9
|
+
|
10
|
+
# Bundle edge Rails instead:
|
11
|
+
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
12
|
+
<%- end -%>
|
13
|
+
|
14
|
+
<% unless options[:skip_activerecord] -%>
|
15
|
+
gem '<%= gem_for_database %>'<% if require_for_database %>, :require => '<%= require_for_database %>'<% end %>
|
16
|
+
<% end -%>
|
17
|
+
|
18
|
+
# Use unicorn as the web server
|
19
|
+
# gem 'unicorn'
|
20
|
+
|
21
|
+
# Deploy with Capistrano
|
22
|
+
# gem 'capistrano'
|
23
|
+
|
24
|
+
# Bundle the extra gems:
|
25
|
+
# gem 'bj'
|
26
|
+
# gem 'nokogiri', '1.4.1'
|
27
|
+
# gem 'sqlite3-ruby', :require => 'sqlite3'
|
28
|
+
# gem 'aws-s3', :require => 'aws/s3'
|
29
|
+
|
30
|
+
# Bundle gems for certain environments:
|
31
|
+
# gem 'rspec', :group => :test
|
32
|
+
# group :test do
|
33
|
+
# gem 'webrat'
|
34
|
+
# end
|
@@ -29,14 +29,15 @@ link:files/vendor/rails/actionpack/README.html.
|
|
29
29
|
|
30
30
|
1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
|
31
31
|
and your application name. Ex: rails myapp
|
32
|
-
2. Change directory into myapp and start the web server: <tt>
|
32
|
+
2. Change directory into myapp and start the web server: <tt>rails server</tt> (run with --help for options)
|
33
33
|
3. Go to http://localhost:3000/ and get "Welcome aboard: You're riding the Rails!"
|
34
34
|
4. Follow the guidelines to start developing your application
|
35
35
|
|
36
36
|
|
37
37
|
== Web Servers
|
38
38
|
|
39
|
-
By default, Rails will try to use Mongrel if it's
|
39
|
+
By default, Rails will try to use Mongrel if it's installed when started with <tt>rails server</tt>, otherwise
|
40
|
+
Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
|
40
41
|
with a variety of other web servers.
|
41
42
|
|
42
43
|
Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
|
@@ -164,20 +165,20 @@ Finally, when you're ready to resume execution, you enter "cont"
|
|
164
165
|
|
165
166
|
== Console
|
166
167
|
|
167
|
-
You can interact with the domain model by starting the console through <tt>
|
168
|
+
You can interact with the domain model by starting the console through <tt>rails console</tt>.
|
168
169
|
Here you'll have all parts of the application configured, just like it is when the
|
169
170
|
application is running. You can inspect domain models, change values, and save to the
|
170
171
|
database. Starting the script without arguments will launch it in the development environment.
|
171
|
-
Passing an argument will specify a different environment, like <tt>
|
172
|
+
Passing an argument will specify a different environment, like <tt>rails console production</tt>.
|
172
173
|
|
173
174
|
To reload your controllers and models after launching the console run <tt>reload!</tt>
|
174
175
|
|
175
176
|
== dbconsole
|
176
177
|
|
177
|
-
You can go to the command line of your database directly through <tt>
|
178
|
+
You can go to the command line of your database directly through <tt>rails dbconsole</tt>.
|
178
179
|
You would be connected to the database with the credentials defined in database.yml.
|
179
180
|
Starting the script without arguments will connect you to the development database. Passing an
|
180
|
-
argument will connect you to a different database, like <tt>
|
181
|
+
argument will connect you to a different database, like <tt>rails dbconsole production</tt>.
|
181
182
|
Currently works for mysql, postgresql and sqlite.
|
182
183
|
|
183
184
|
== Description of Contents
|
@@ -207,7 +208,7 @@ app/views/layouts
|
|
207
208
|
|
208
209
|
app/helpers
|
209
210
|
Holds view helpers that should be named like weblogs_helper.rb. These are generated
|
210
|
-
for you automatically when using
|
211
|
+
for you automatically when using rails generate for controllers. Helpers can be used to
|
211
212
|
wrap functionality for your views into methods.
|
212
213
|
|
213
214
|
config
|
@@ -234,7 +235,7 @@ script
|
|
234
235
|
Helper scripts for automation and generation.
|
235
236
|
|
236
237
|
test
|
237
|
-
Unit and functional tests along with fixtures. When using the
|
238
|
+
Unit and functional tests along with fixtures. When using the rails generate command, template
|
238
239
|
test files will be generated for you and placed in this directory.
|
239
240
|
|
240
241
|
vendor
|