railties 3.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2201 -0
- data/README +286 -0
- data/bin/rails +11 -0
- data/builtin/rails_info/rails/info.rb +147 -0
- data/builtin/rails_info/rails/info_controller.rb +15 -0
- data/builtin/rails_info/rails/info_helper.rb +2 -0
- data/builtin/routes.rb +3 -0
- data/guides/files/javascripts/code_highlighter.js +188 -0
- data/guides/files/javascripts/guides.js +7 -0
- data/guides/files/javascripts/highlighters.js +90 -0
- data/guides/files/stylesheets/main.css +441 -0
- data/guides/files/stylesheets/print.css +52 -0
- data/guides/files/stylesheets/reset.css +43 -0
- data/guides/files/stylesheets/style.css +13 -0
- data/guides/files/stylesheets/syntax.css +31 -0
- data/guides/images/belongs_to.png +0 -0
- data/guides/images/book_icon.gif +0 -0
- data/guides/images/bullet.gif +0 -0
- data/guides/images/chapters_icon.gif +0 -0
- data/guides/images/check_bullet.gif +0 -0
- data/guides/images/credits_pic_blank.gif +0 -0
- data/guides/images/csrf.png +0 -0
- data/guides/images/customized_error_messages.png +0 -0
- data/guides/images/error_messages.png +0 -0
- data/guides/images/feature_tile.gif +0 -0
- data/guides/images/footer_tile.gif +0 -0
- data/guides/images/fxn.png +0 -0
- data/guides/images/grey_bullet.gif +0 -0
- data/guides/images/habtm.png +0 -0
- data/guides/images/has_many.png +0 -0
- data/guides/images/has_many_through.png +0 -0
- data/guides/images/has_one.png +0 -0
- data/guides/images/has_one_through.png +0 -0
- data/guides/images/header_backdrop.png +0 -0
- data/guides/images/header_tile.gif +0 -0
- data/guides/images/i18n/demo_localized_pirate.png +0 -0
- data/guides/images/i18n/demo_translated_en.png +0 -0
- data/guides/images/i18n/demo_translated_pirate.png +0 -0
- data/guides/images/i18n/demo_translation_missing.png +0 -0
- data/guides/images/i18n/demo_untranslated.png +0 -0
- data/guides/images/icons/README +5 -0
- data/guides/images/icons/callouts/1.png +0 -0
- data/guides/images/icons/callouts/10.png +0 -0
- data/guides/images/icons/callouts/11.png +0 -0
- data/guides/images/icons/callouts/12.png +0 -0
- data/guides/images/icons/callouts/13.png +0 -0
- data/guides/images/icons/callouts/14.png +0 -0
- data/guides/images/icons/callouts/15.png +0 -0
- data/guides/images/icons/callouts/2.png +0 -0
- data/guides/images/icons/callouts/3.png +0 -0
- data/guides/images/icons/callouts/4.png +0 -0
- data/guides/images/icons/callouts/5.png +0 -0
- data/guides/images/icons/callouts/6.png +0 -0
- data/guides/images/icons/callouts/7.png +0 -0
- data/guides/images/icons/callouts/8.png +0 -0
- data/guides/images/icons/callouts/9.png +0 -0
- data/guides/images/icons/caution.png +0 -0
- data/guides/images/icons/example.png +0 -0
- data/guides/images/icons/home.png +0 -0
- data/guides/images/icons/important.png +0 -0
- data/guides/images/icons/next.png +0 -0
- data/guides/images/icons/note.png +0 -0
- data/guides/images/icons/prev.png +0 -0
- data/guides/images/icons/tip.png +0 -0
- data/guides/images/icons/up.png +0 -0
- data/guides/images/icons/warning.png +0 -0
- data/guides/images/nav_arrow.gif +0 -0
- data/guides/images/polymorphic.png +0 -0
- data/guides/images/posts_index.png +0 -0
- data/guides/images/rails_guides_logo.gif +0 -0
- data/guides/images/rails_logo_remix.gif +0 -0
- data/guides/images/rails_welcome.png +0 -0
- data/guides/images/session_fixation.png +0 -0
- data/guides/images/tab_grey.gif +0 -0
- data/guides/images/tab_info.gif +0 -0
- data/guides/images/tab_note.gif +0 -0
- data/guides/images/tab_red.gif +0 -0
- data/guides/images/tab_yellow.gif +0 -0
- data/guides/images/tab_yellow.png +0 -0
- data/guides/images/validation_error_messages.png +0 -0
- data/guides/rails_guides.rb +44 -0
- data/guides/rails_guides/generator.rb +178 -0
- data/guides/rails_guides/helpers.rb +34 -0
- data/guides/rails_guides/indexer.rb +55 -0
- data/guides/rails_guides/levenshtein.rb +31 -0
- data/guides/rails_guides/textile_extensions.rb +41 -0
- data/guides/source/2_2_release_notes.textile +422 -0
- data/guides/source/2_3_release_notes.textile +610 -0
- data/guides/source/3_0_release_notes.textile +560 -0
- data/guides/source/action_controller_overview.textile +783 -0
- data/guides/source/action_mailer_basics.textile +437 -0
- data/guides/source/action_view_overview.textile +1481 -0
- data/guides/source/active_record_basics.textile +204 -0
- data/guides/source/active_record_querying.textile +961 -0
- data/guides/source/active_support_core_extensions.textile +1835 -0
- data/guides/source/activerecord_validations_callbacks.textile +1127 -0
- data/guides/source/ajax_on_rails.textile +342 -0
- data/guides/source/association_basics.textile +1816 -0
- data/guides/source/caching_with_rails.textile +390 -0
- data/guides/source/command_line.textile +589 -0
- data/guides/source/configuring.textile +290 -0
- data/guides/source/contribute.textile +71 -0
- data/guides/source/contributing_to_rails.textile +272 -0
- data/guides/source/credits.textile.erb +52 -0
- data/guides/source/debugging_rails_applications.textile +709 -0
- data/guides/source/form_helpers.textile +768 -0
- data/guides/source/generators.textile +378 -0
- data/guides/source/getting_started.textile +1310 -0
- data/guides/source/i18n.textile +879 -0
- data/guides/source/index.textile.erb +124 -0
- data/guides/source/layout.html.erb +103 -0
- data/guides/source/layouts_and_rendering.textile +979 -0
- data/guides/source/migrations.textile +591 -0
- data/guides/source/nested_model_forms.textile +222 -0
- data/guides/source/performance_testing.textile +531 -0
- data/guides/source/plugins.textile +1512 -0
- data/guides/source/rails_application_templates.textile +238 -0
- data/guides/source/rails_on_rack.textile +306 -0
- data/guides/source/routing.textile +903 -0
- data/guides/source/security.textile +984 -0
- data/guides/source/testing.textile +946 -0
- data/lib/generators/erb.rb +8 -0
- data/lib/generators/erb/controller/controller_generator.rb +21 -0
- data/lib/generators/erb/controller/templates/view.html.erb +2 -0
- data/lib/generators/erb/mailer/mailer_generator.rb +20 -0
- data/lib/generators/erb/mailer/templates/view.text.erb +3 -0
- data/lib/generators/erb/scaffold/scaffold_generator.rb +53 -0
- data/lib/generators/erb/scaffold/templates/_form.html.erb +13 -0
- data/lib/generators/erb/scaffold/templates/edit.html.erb +6 -0
- data/lib/generators/erb/scaffold/templates/index.html.erb +27 -0
- data/lib/generators/erb/scaffold/templates/layout.html.erb +16 -0
- data/lib/generators/erb/scaffold/templates/new.html.erb +5 -0
- data/lib/generators/erb/scaffold/templates/show.html.erb +10 -0
- data/lib/generators/rails/app/USAGE +9 -0
- data/lib/generators/rails/app/app_generator.rb +262 -0
- data/lib/generators/rails/app/templates/Gemfile +34 -0
- data/lib/generators/rails/app/templates/README +243 -0
- data/lib/generators/rails/app/templates/Rakefile +10 -0
- data/lib/generators/rails/app/templates/app/controllers/application_controller.rb +3 -0
- data/lib/generators/rails/app/templates/app/helpers/application_helper.rb +2 -0
- data/lib/generators/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/config.ru +4 -0
- data/lib/generators/rails/app/templates/config/application.rb +51 -0
- data/lib/generators/rails/app/templates/config/boot.rb +17 -0
- data/lib/generators/rails/app/templates/config/databases/frontbase.yml +28 -0
- data/lib/generators/rails/app/templates/config/databases/ibm_db.yml +71 -0
- data/lib/generators/rails/app/templates/config/databases/mysql.yml +60 -0
- data/lib/generators/rails/app/templates/config/databases/oracle.yml +39 -0
- data/lib/generators/rails/app/templates/config/databases/postgresql.yml +51 -0
- data/lib/generators/rails/app/templates/config/databases/sqlite3.yml +22 -0
- data/lib/generators/rails/app/templates/config/environment.rb +5 -0
- data/lib/generators/rails/app/templates/config/environments/development.rb.tt +19 -0
- data/lib/generators/rails/app/templates/config/environments/production.rb.tt +33 -0
- data/lib/generators/rails/app/templates/config/environments/test.rb.tt +29 -0
- data/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/generators/rails/app/templates/config/initializers/cookie_verification_secret.rb.tt +7 -0
- data/lib/generators/rails/app/templates/config/initializers/inflections.rb +10 -0
- data/lib/generators/rails/app/templates/config/initializers/mime_types.rb +5 -0
- data/lib/generators/rails/app/templates/config/initializers/session_store.rb.tt +15 -0
- data/lib/generators/rails/app/templates/config/locales/en.yml +5 -0
- data/lib/generators/rails/app/templates/config/routes.rb +58 -0
- data/lib/generators/rails/app/templates/db/seeds.rb +7 -0
- data/lib/generators/rails/app/templates/doc/README_FOR_APP +2 -0
- data/lib/generators/rails/app/templates/gitignore +4 -0
- data/lib/generators/rails/app/templates/public/404.html +26 -0
- data/lib/generators/rails/app/templates/public/422.html +26 -0
- data/lib/generators/rails/app/templates/public/500.html +26 -0
- data/lib/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/generators/rails/app/templates/public/images/rails.png +0 -0
- data/lib/generators/rails/app/templates/public/index.html +278 -0
- data/lib/generators/rails/app/templates/public/javascripts/application.js +2 -0
- data/lib/generators/rails/app/templates/public/javascripts/controls.js +963 -0
- data/lib/generators/rails/app/templates/public/javascripts/dragdrop.js +973 -0
- data/lib/generators/rails/app/templates/public/javascripts/effects.js +1128 -0
- data/lib/generators/rails/app/templates/public/javascripts/prototype.js +4320 -0
- data/lib/generators/rails/app/templates/public/javascripts/rails.js +110 -0
- data/lib/generators/rails/app/templates/public/robots.txt +5 -0
- data/lib/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/script/rails +9 -0
- data/lib/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/performance/browsing_test.rb +9 -0
- data/lib/generators/rails/app/templates/test/test_helper.rb +13 -0
- data/lib/generators/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/generators/rails/controller/USAGE +18 -0
- data/lib/generators/rails/controller/controller_generator.rb +14 -0
- data/lib/generators/rails/controller/templates/controller.rb +7 -0
- data/lib/generators/rails/generator/USAGE +11 -0
- data/lib/generators/rails/generator/generator_generator.rb +25 -0
- data/lib/generators/rails/generator/templates/%file_name%_generator.rb.tt +5 -0
- data/lib/generators/rails/generator/templates/USAGE.tt +8 -0
- data/lib/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/generators/rails/helper/USAGE +17 -0
- data/lib/generators/rails/helper/helper_generator.rb +13 -0
- data/lib/generators/rails/helper/templates/helper.rb +2 -0
- data/lib/generators/rails/integration_test/USAGE +10 -0
- data/lib/generators/rails/integration_test/integration_test_generator.rb +7 -0
- data/lib/generators/rails/mailer/USAGE +15 -0
- data/lib/generators/rails/mailer/mailer_generator.rb +14 -0
- data/lib/generators/rails/mailer/templates/mailer.rb +16 -0
- data/lib/generators/rails/metal/USAGE +8 -0
- data/lib/generators/rails/metal/metal_generator.rb +11 -0
- data/lib/generators/rails/metal/templates/metal.rb +12 -0
- data/lib/generators/rails/migration/USAGE +29 -0
- data/lib/generators/rails/migration/migration_generator.rb +8 -0
- data/lib/generators/rails/model/USAGE +30 -0
- data/lib/generators/rails/model/model_generator.rb +8 -0
- data/lib/generators/rails/model_subclass/model_subclass_generator.rb +12 -0
- data/lib/generators/rails/observer/USAGE +12 -0
- data/lib/generators/rails/observer/observer_generator.rb +7 -0
- data/lib/generators/rails/performance_test/USAGE +10 -0
- data/lib/generators/rails/performance_test/performance_test_generator.rb +7 -0
- data/lib/generators/rails/plugin/USAGE +13 -0
- data/lib/generators/rails/plugin/plugin_generator.rb +47 -0
- data/lib/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
- data/lib/generators/rails/plugin/templates/README.tt +13 -0
- data/lib/generators/rails/plugin/templates/Rakefile.tt +10 -0
- data/lib/generators/rails/plugin/templates/init.rb +1 -0
- data/lib/generators/rails/plugin/templates/install.rb +1 -0
- data/lib/generators/rails/plugin/templates/lib/%file_name%.rb.tt +1 -0
- data/lib/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +4 -0
- data/lib/generators/rails/plugin/templates/uninstall.rb +1 -0
- data/lib/generators/rails/resource/USAGE +23 -0
- data/lib/generators/rails/resource/resource_generator.rb +34 -0
- data/lib/generators/rails/scaffold/USAGE +29 -0
- data/lib/generators/rails/scaffold/scaffold_generator.rb +13 -0
- data/lib/generators/rails/scaffold_controller/USAGE +20 -0
- data/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb +27 -0
- data/lib/generators/rails/scaffold_controller/templates/controller.rb +85 -0
- data/lib/generators/rails/session_migration/USAGE +8 -0
- data/lib/generators/rails/session_migration/session_migration_generator.rb +8 -0
- data/lib/generators/rails/stylesheets/USAGE +5 -0
- data/lib/generators/rails/stylesheets/stylesheets_generator.rb +9 -0
- data/lib/generators/rails/stylesheets/templates/scaffold.css +61 -0
- data/lib/generators/test_unit.rb +8 -0
- data/lib/generators/test_unit/controller/controller_generator.rb +14 -0
- data/lib/generators/test_unit/controller/templates/functional_test.rb +8 -0
- data/lib/generators/test_unit/helper/helper_generator.rb +13 -0
- data/lib/generators/test_unit/helper/templates/helper_test.rb +4 -0
- data/lib/generators/test_unit/integration/integration_generator.rb +13 -0
- data/lib/generators/test_unit/integration/templates/integration_test.rb +10 -0
- data/lib/generators/test_unit/mailer/mailer_generator.rb +21 -0
- data/lib/generators/test_unit/mailer/templates/fixture +3 -0
- data/lib/generators/test_unit/mailer/templates/functional_test.rb +22 -0
- data/lib/generators/test_unit/model/model_generator.rb +24 -0
- data/lib/generators/test_unit/model/templates/fixtures.yml +23 -0
- data/lib/generators/test_unit/model/templates/unit_test.rb +8 -0
- data/lib/generators/test_unit/observer/observer_generator.rb +13 -0
- data/lib/generators/test_unit/observer/templates/unit_test.rb +8 -0
- data/lib/generators/test_unit/performance/performance_generator.rb +13 -0
- data/lib/generators/test_unit/performance/templates/performance_test.rb +9 -0
- data/lib/generators/test_unit/plugin/plugin_generator.rb +13 -0
- data/lib/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +8 -0
- data/lib/generators/test_unit/plugin/templates/test_helper.rb +3 -0
- data/lib/generators/test_unit/scaffold/scaffold_generator.rb +18 -0
- data/lib/generators/test_unit/scaffold/templates/functional_test.rb +47 -0
- data/lib/rails.rb +95 -0
- data/lib/rails/all.rb +14 -0
- data/lib/rails/application.rb +125 -0
- data/lib/rails/application/bootstrap.rb +85 -0
- data/lib/rails/application/configurable.rb +19 -0
- data/lib/rails/application/configuration.rb +86 -0
- data/lib/rails/application/finisher.rb +49 -0
- data/lib/rails/application/metal_loader.rb +50 -0
- data/lib/rails/application/railties.rb +31 -0
- data/lib/rails/application/routes_reloader.rb +46 -0
- data/lib/rails/backtrace_cleaner.rb +54 -0
- data/lib/rails/code_statistics.rb +107 -0
- data/lib/rails/commands.rb +72 -0
- data/lib/rails/commands/application.rb +13 -0
- data/lib/rails/commands/console.rb +55 -0
- data/lib/rails/commands/dbconsole.rb +104 -0
- data/lib/rails/commands/destroy.rb +9 -0
- data/lib/rails/commands/generate.rb +9 -0
- data/lib/rails/commands/performance/benchmarker.rb +23 -0
- data/lib/rails/commands/performance/profiler.rb +46 -0
- data/lib/rails/commands/plugin.rb +542 -0
- data/lib/rails/commands/runner.rb +51 -0
- data/lib/rails/commands/server.rb +75 -0
- data/lib/rails/commands/update.rb +9 -0
- data/lib/rails/configuration.rb +191 -0
- data/lib/rails/console/app.rb +33 -0
- data/lib/rails/console/helpers.rb +5 -0
- data/lib/rails/console/sandbox.rb +6 -0
- data/lib/rails/deprecation.rb +62 -0
- data/lib/rails/dispatcher.rb +24 -0
- data/lib/rails/engine.rb +130 -0
- data/lib/rails/engine/configurable.rb +25 -0
- data/lib/rails/engine/configuration.rb +49 -0
- data/lib/rails/generators.rb +289 -0
- data/lib/rails/generators/actions.rb +309 -0
- data/lib/rails/generators/active_model.rb +78 -0
- data/lib/rails/generators/base.rb +362 -0
- data/lib/rails/generators/generated_attribute.rb +48 -0
- data/lib/rails/generators/migration.rb +64 -0
- data/lib/rails/generators/named_base.rb +95 -0
- data/lib/rails/generators/resource_helpers.rb +80 -0
- data/lib/rails/generators/test_case.rb +239 -0
- data/lib/rails/initializable.rb +97 -0
- data/lib/rails/paths.rb +144 -0
- data/lib/rails/performance_test_help.rb +3 -0
- data/lib/rails/plugin.rb +64 -0
- data/lib/rails/rack.rb +8 -0
- data/lib/rails/rack/debugger.rb +23 -0
- data/lib/rails/rack/log_tailer.rb +33 -0
- data/lib/rails/rack/logger.rb +34 -0
- data/lib/rails/rack/static.rb +5 -0
- data/lib/rails/railtie.rb +74 -0
- data/lib/rails/railtie/configurable.rb +23 -0
- data/lib/rails/railtie/configuration.rb +9 -0
- data/lib/rails/railties_path.rb +1 -0
- data/lib/rails/ruby_version_check.rb +10 -0
- data/lib/rails/rubyprof_ext.rb +35 -0
- data/lib/rails/source_annotation_extractor.rb +102 -0
- data/lib/rails/subscriber.rb +108 -0
- data/lib/rails/subscriber/test_helper.rb +98 -0
- data/lib/rails/tasks.rb +16 -0
- data/lib/rails/tasks/annotations.rake +20 -0
- data/lib/rails/tasks/documentation.rake +96 -0
- data/lib/rails/tasks/framework.rake +69 -0
- data/lib/rails/tasks/log.rake +9 -0
- data/lib/rails/tasks/middleware.rake +7 -0
- data/lib/rails/tasks/misc.rake +71 -0
- data/lib/rails/tasks/routes.rake +17 -0
- data/lib/rails/tasks/statistics.rake +16 -0
- data/lib/rails/tasks/tmp.rake +37 -0
- data/lib/rails/test_help.rb +30 -0
- data/lib/rails/test_unit/railtie.rb +17 -0
- data/lib/rails/test_unit/testing.rake +130 -0
- data/lib/rails/version.rb +9 -0
- data/lib/rails/webrick_server.rb +156 -0
- metadata +427 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'generators/erb'
|
2
|
+
|
3
|
+
module Erb
|
4
|
+
module Generators
|
5
|
+
class ControllerGenerator < Base
|
6
|
+
argument :actions, :type => :array, :default => [], :banner => "action action"
|
7
|
+
|
8
|
+
def create_view_files
|
9
|
+
base_path = File.join("app/views", class_path, file_name)
|
10
|
+
empty_directory base_path
|
11
|
+
|
12
|
+
actions.each do |action|
|
13
|
+
@action = action
|
14
|
+
@path = File.join(base_path, "#{action}.html.erb")
|
15
|
+
|
16
|
+
template 'view.html.erb', @path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'generators/erb'
|
2
|
+
|
3
|
+
module Erb
|
4
|
+
module Generators
|
5
|
+
class MailerGenerator < Base
|
6
|
+
argument :actions, :type => :array, :default => [], :banner => "method method"
|
7
|
+
|
8
|
+
def create_view_folder
|
9
|
+
empty_directory File.join("app/views", file_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_view_files
|
13
|
+
actions.each do |action|
|
14
|
+
@action, @path = action, File.join(file_path, action)
|
15
|
+
template "view.text.erb", File.join("app/views", "#{@path}.text.erb")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'generators/erb'
|
2
|
+
require 'rails/generators/resource_helpers'
|
3
|
+
|
4
|
+
module Erb
|
5
|
+
module Generators
|
6
|
+
class ScaffoldGenerator < Base
|
7
|
+
include Rails::Generators::ResourceHelpers
|
8
|
+
|
9
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
10
|
+
|
11
|
+
class_option :layout, :type => :boolean
|
12
|
+
class_option :singleton, :type => :boolean, :desc => "Supply to skip index view"
|
13
|
+
|
14
|
+
def create_root_folder
|
15
|
+
empty_directory File.join("app/views", controller_file_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def copy_index_file
|
19
|
+
return if options[:singleton]
|
20
|
+
copy_view :index
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_edit_file
|
24
|
+
copy_view :edit
|
25
|
+
end
|
26
|
+
|
27
|
+
def copy_show_file
|
28
|
+
copy_view :show
|
29
|
+
end
|
30
|
+
|
31
|
+
def copy_new_file
|
32
|
+
copy_view :new
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_form_file
|
36
|
+
copy_view :_form
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy_layout_file
|
40
|
+
return unless options[:layout]
|
41
|
+
template "layout.html.erb",
|
42
|
+
File.join("app/views/layouts", controller_class_path, "#{controller_file_name}.html.erb")
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def copy_view(view)
|
48
|
+
template "#{view}.html.erb", File.join("app/views", controller_file_path, "#{view}.html.erb")
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%% form_for(@<%= singular_name %>) do |f| %>
|
2
|
+
<%%= f.error_messages %>
|
3
|
+
|
4
|
+
<% for attribute in attributes -%>
|
5
|
+
<div class="field">
|
6
|
+
<%%= f.label :<%= attribute.name %> %><br />
|
7
|
+
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
8
|
+
</div>
|
9
|
+
<% end -%>
|
10
|
+
<div class="actions">
|
11
|
+
<%%= f.submit %>
|
12
|
+
</div>
|
13
|
+
<%% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<th><%= attribute.human_name %></th>
|
7
|
+
<% end -%>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
<th></th>
|
11
|
+
</tr>
|
12
|
+
|
13
|
+
<%% @<%= plural_name %>.each do |<%= singular_name %>| %>
|
14
|
+
<tr>
|
15
|
+
<% for attribute in attributes -%>
|
16
|
+
<td><%%= <%= singular_name %>.<%= attribute.name %> %></td>
|
17
|
+
<% end -%>
|
18
|
+
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
19
|
+
<td><%%= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
20
|
+
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
21
|
+
</tr>
|
22
|
+
<%% end %>
|
23
|
+
</table>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
|
27
|
+
<%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
5
|
+
<%%= stylesheet_link_tag 'scaffold' %>
|
6
|
+
<%%= javascript_include_tag :defaults %>
|
7
|
+
<%%= csrf_meta_tag %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<p class="notice"><%%= notice %></p>
|
12
|
+
|
13
|
+
<%%= yield %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% for attribute in attributes -%>
|
2
|
+
<p>
|
3
|
+
<b><%= attribute.human_name %>:</b>
|
4
|
+
<%%= @<%= singular_name %>.<%= attribute.name %> %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
<%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
10
|
+
<%%= link_to 'Back', <%= plural_name %>_path %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Description:
|
2
|
+
The 'rails' command creates a new Rails application with a default
|
3
|
+
directory structure and configuration at the path you specify.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
rails ~/Code/Ruby/weblog
|
7
|
+
|
8
|
+
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
|
9
|
+
See the README in the newly created application to get going.
|
@@ -0,0 +1,262 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'active_support/secure_random'
|
3
|
+
require 'rails/version' unless defined?(Rails::VERSION)
|
4
|
+
|
5
|
+
module Rails::Generators
|
6
|
+
# We need to store the RAILS_DEV_PATH in a constant, otherwise the path
|
7
|
+
# can change in Ruby 1.8.7 when we FileUtils.cd.
|
8
|
+
RAILS_DEV_PATH = File.expand_path("../../../../..", File.dirname(__FILE__))
|
9
|
+
|
10
|
+
class AppGenerator < Base
|
11
|
+
DATABASES = %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
12
|
+
|
13
|
+
attr_accessor :rails_template
|
14
|
+
add_shebang_option!
|
15
|
+
|
16
|
+
argument :app_path, :type => :string
|
17
|
+
|
18
|
+
class_option :database, :type => :string, :aliases => "-d", :default => "sqlite3",
|
19
|
+
:desc => "Preconfigure for selected database (options: #{DATABASES.join('/')})"
|
20
|
+
|
21
|
+
class_option :template, :type => :string, :aliases => "-m",
|
22
|
+
:desc => "Path to an application template (can be a filesystem path or URL)."
|
23
|
+
|
24
|
+
class_option :dev, :type => :boolean, :default => false,
|
25
|
+
:desc => "Setup the application with Gemfile pointing to your Rails checkout"
|
26
|
+
|
27
|
+
class_option :edge, :type => :boolean, :default => false,
|
28
|
+
:desc => "Setup the application with Gemfile pointing to Rails repository"
|
29
|
+
|
30
|
+
class_option :skip_activerecord, :type => :boolean, :aliases => "-O", :default => false,
|
31
|
+
:desc => "Skip ActiveRecord files"
|
32
|
+
|
33
|
+
class_option :skip_testunit, :type => :boolean, :aliases => "-T", :default => false,
|
34
|
+
:desc => "Skip TestUnit files"
|
35
|
+
|
36
|
+
class_option :skip_prototype, :type => :boolean, :aliases => "-J", :default => false,
|
37
|
+
:desc => "Skip Prototype files"
|
38
|
+
|
39
|
+
class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
|
40
|
+
:desc => "Skip Git ignores and keeps"
|
41
|
+
|
42
|
+
# Add bin/rails options
|
43
|
+
class_option :version, :type => :boolean, :aliases => "-v", :group => :rails,
|
44
|
+
:desc => "Show Rails version number and quit"
|
45
|
+
|
46
|
+
class_option :help, :type => :boolean, :aliases => "-h", :group => :rails,
|
47
|
+
:desc => "Show this help message and quit"
|
48
|
+
|
49
|
+
def initialize(*args)
|
50
|
+
super
|
51
|
+
if !options[:skip_activerecord] && !DATABASES.include?(options[:database])
|
52
|
+
raise Error, "Invalid value for --database option. Supported for preconfiguration are: #{DATABASES.join(", ")}."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_root
|
57
|
+
self.destination_root = File.expand_path(app_path, destination_root)
|
58
|
+
valid_app_const?
|
59
|
+
|
60
|
+
empty_directory '.'
|
61
|
+
set_default_accessors!
|
62
|
+
FileUtils.cd(destination_root)
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_root_files
|
66
|
+
copy_file "README"
|
67
|
+
copy_file "gitignore", ".gitignore" unless options[:skip_git]
|
68
|
+
template "Rakefile"
|
69
|
+
template "config.ru"
|
70
|
+
template "Gemfile"
|
71
|
+
end
|
72
|
+
|
73
|
+
def create_app_files
|
74
|
+
directory "app"
|
75
|
+
end
|
76
|
+
|
77
|
+
def create_config_files
|
78
|
+
empty_directory "config"
|
79
|
+
|
80
|
+
inside "config" do
|
81
|
+
template "routes.rb"
|
82
|
+
template "application.rb"
|
83
|
+
template "environment.rb"
|
84
|
+
|
85
|
+
directory "environments"
|
86
|
+
directory "initializers"
|
87
|
+
directory "locales"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_boot_file
|
92
|
+
template "config/boot.rb"
|
93
|
+
end
|
94
|
+
|
95
|
+
def create_activerecord_files
|
96
|
+
return if options[:skip_activerecord]
|
97
|
+
template "config/databases/#{options[:database]}.yml", "config/database.yml"
|
98
|
+
end
|
99
|
+
|
100
|
+
def create_db_files
|
101
|
+
directory "db"
|
102
|
+
end
|
103
|
+
|
104
|
+
def create_doc_files
|
105
|
+
directory "doc"
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_lib_files
|
109
|
+
empty_directory "lib"
|
110
|
+
empty_directory_with_gitkeep "lib/tasks"
|
111
|
+
end
|
112
|
+
|
113
|
+
def create_log_files
|
114
|
+
empty_directory "log"
|
115
|
+
|
116
|
+
inside "log" do
|
117
|
+
%w( server production development test ).each do |file|
|
118
|
+
create_file "#{file}.log"
|
119
|
+
chmod "#{file}.log", 0666, :verbose => false
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def create_public_files
|
125
|
+
directory "public", "public", :recursive => false # Do small steps, so anyone can overwrite it.
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_public_image_files
|
129
|
+
directory "public/images"
|
130
|
+
end
|
131
|
+
|
132
|
+
def create_public_stylesheets_files
|
133
|
+
empty_directory_with_gitkeep "public/stylesheets"
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_prototype_files
|
137
|
+
return if options[:skip_prototype]
|
138
|
+
directory "public/javascripts"
|
139
|
+
end
|
140
|
+
|
141
|
+
def create_script_files
|
142
|
+
directory "script" do |content|
|
143
|
+
"#{shebang}\n" + content
|
144
|
+
end
|
145
|
+
chmod "script", 0755, :verbose => false
|
146
|
+
end
|
147
|
+
|
148
|
+
def create_test_files
|
149
|
+
return if options[:skip_testunit]
|
150
|
+
directory "test"
|
151
|
+
end
|
152
|
+
|
153
|
+
def create_tmp_files
|
154
|
+
empty_directory "tmp"
|
155
|
+
|
156
|
+
inside "tmp" do
|
157
|
+
%w(sessions sockets cache pids).each do |dir|
|
158
|
+
empty_directory(dir)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def create_vendor_files
|
164
|
+
empty_directory_with_gitkeep "vendor/plugins"
|
165
|
+
end
|
166
|
+
|
167
|
+
def apply_rails_template
|
168
|
+
apply rails_template if rails_template
|
169
|
+
rescue Thor::Error, LoadError, Errno::ENOENT => e
|
170
|
+
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
|
171
|
+
end
|
172
|
+
|
173
|
+
def bundle_if_dev_or_edge
|
174
|
+
run "bundle install" if dev_or_edge?
|
175
|
+
end
|
176
|
+
|
177
|
+
protected
|
178
|
+
|
179
|
+
def self.banner
|
180
|
+
"rails #{self.arguments.map(&:usage).join(' ')} [options]"
|
181
|
+
end
|
182
|
+
|
183
|
+
def set_default_accessors!
|
184
|
+
self.rails_template = case options[:template]
|
185
|
+
when /^http:\/\//
|
186
|
+
options[:template]
|
187
|
+
when String
|
188
|
+
File.expand_path(options[:template], Dir.pwd)
|
189
|
+
else
|
190
|
+
options[:template]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Define file as an alias to create_file for backwards compatibility.
|
195
|
+
def file(*args, &block)
|
196
|
+
create_file(*args, &block)
|
197
|
+
end
|
198
|
+
|
199
|
+
def app_name
|
200
|
+
@app_name ||= File.basename(destination_root)
|
201
|
+
end
|
202
|
+
|
203
|
+
def app_const_base
|
204
|
+
@app_const_base ||= app_name.gsub(/\W/, '_').squeeze('_').camelize
|
205
|
+
end
|
206
|
+
|
207
|
+
def app_const
|
208
|
+
@app_const ||= "#{app_const_base}::Application"
|
209
|
+
end
|
210
|
+
|
211
|
+
def valid_app_const?
|
212
|
+
case app_const
|
213
|
+
when /^\d/
|
214
|
+
raise Error, "Invalid application name #{app_name}. Please give a name which does not start with numbers."
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def app_secret
|
219
|
+
ActiveSupport::SecureRandom.hex(64)
|
220
|
+
end
|
221
|
+
|
222
|
+
def dev_or_edge?
|
223
|
+
options.dev? || options.edge?
|
224
|
+
end
|
225
|
+
|
226
|
+
def gem_for_database
|
227
|
+
# %w( mysql oracle postgresql sqlite3 frontbase ibm_db )
|
228
|
+
case options[:database]
|
229
|
+
when "oracle" then "ruby-oci8"
|
230
|
+
when "postgresql" then "pg"
|
231
|
+
when "sqlite3" then "sqlite3-ruby"
|
232
|
+
when "frontbase" then "ruby-frontbase"
|
233
|
+
else options[:database]
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def require_for_database
|
238
|
+
case options[:database]
|
239
|
+
when "sqlite3" then "sqlite3"
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def mysql_socket
|
244
|
+
@mysql_socket ||= [
|
245
|
+
"/tmp/mysql.sock", # default
|
246
|
+
"/var/run/mysqld/mysqld.sock", # debian/gentoo
|
247
|
+
"/var/tmp/mysql.sock", # freebsd
|
248
|
+
"/var/lib/mysql/mysql.sock", # fedora
|
249
|
+
"/opt/local/lib/mysql/mysql.sock", # fedora
|
250
|
+
"/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
|
251
|
+
"/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
|
252
|
+
"/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
|
253
|
+
"/opt/lampp/var/mysql/mysql.sock" # xampp for linux
|
254
|
+
].find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
255
|
+
end
|
256
|
+
|
257
|
+
def empty_directory_with_gitkeep(destination, config = {})
|
258
|
+
empty_directory(destination, config)
|
259
|
+
create_file("#{destination}/.gitkeep") unless options[:skip_git]
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|