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,30 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new model. Pass the model name, either CamelCased or
|
3
|
+
under_scored, and an optional list of attribute pairs as arguments.
|
4
|
+
|
5
|
+
Attribute pairs are field:type arguments specifying the
|
6
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
7
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
8
|
+
|
9
|
+
You don't have to think up every attribute up front, but it helps to
|
10
|
+
sketch out a few so you can start working with the model immediately.
|
11
|
+
|
12
|
+
This generator invokes your configured ORM and test framework, which
|
13
|
+
defaults to ActiveRecord and TestUnit.
|
14
|
+
|
15
|
+
Finally, if --parent option is given, it's used as superclass of the
|
16
|
+
created model. This allows you create Single Table Inheritance models.
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
`./script/generate model account`
|
20
|
+
|
21
|
+
For ActiveRecord and TestUnit it creates:
|
22
|
+
|
23
|
+
Model: app/models/account.rb
|
24
|
+
Test: test/unit/account_test.rb
|
25
|
+
Fixtures: test/fixtures/accounts.yml
|
26
|
+
Migration: db/migrate/XXX_add_accounts.rb
|
27
|
+
|
28
|
+
`./script/generate model post title:string body:text published:boolean`
|
29
|
+
|
30
|
+
Creates a Post model with a string title, text body, and published flag.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rails
|
2
|
+
module Generators
|
3
|
+
# TODO Deprecate me in a release > Rails 3.0
|
4
|
+
class ModelSubclassGenerator < Base
|
5
|
+
desc "model_subclass is deprecated. Invoke model with --parent option instead."
|
6
|
+
|
7
|
+
def say_deprecation_warn
|
8
|
+
say self.class.desc
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new observer. Pass the observer name, either CamelCased or
|
3
|
+
under_scored, as an argument.
|
4
|
+
|
5
|
+
This generator only invokes your ORM and test framework generators.
|
6
|
+
|
7
|
+
Example:
|
8
|
+
`./script/generate observer Account`
|
9
|
+
|
10
|
+
For ActiveRecord and TestUnit it creates:
|
11
|
+
Observer: app/models/account_observer.rb
|
12
|
+
TestUnit: test/unit/account_observer_test.rb
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new performance test. Pass the name of the test, either
|
3
|
+
CamelCased or under_scored, as an argument.
|
4
|
+
|
5
|
+
This generator invokes the current performance tool, which defaults to
|
6
|
+
TestUnit.
|
7
|
+
|
8
|
+
Example:
|
9
|
+
`./script/generate performance_test GeneralStories` creates a GeneralStories
|
10
|
+
performance test in test/performance/general_stories_test.rb
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new plugin at vendor/plugins. Pass the plugin name, either
|
3
|
+
CamelCased or under_scored, as an argument.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
`./script/generate plugin BrowserFilters`
|
7
|
+
|
8
|
+
creates a standard browser_filters plugin:
|
9
|
+
vendor/plugins/browser_filters/README
|
10
|
+
vendor/plugins/browser_filters/init.rb
|
11
|
+
vendor/plugins/browser_filters/install.rb
|
12
|
+
vendor/plugins/browser_filters/lib/browser_filters.rb
|
13
|
+
vendor/plugins/browser_filters/test/browser_filters_test.rb
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'generators/rails/generator/generator_generator'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generators
|
5
|
+
class PluginGenerator < NamedBase
|
6
|
+
class_option :tasks, :desc => "When supplied creates tasks base files."
|
7
|
+
|
8
|
+
check_class_collision
|
9
|
+
|
10
|
+
def create_root_files
|
11
|
+
directory '.', plugin_dir, :recursive => false
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_lib_files
|
15
|
+
directory 'lib', plugin_dir('lib'), :recursive => false
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_tasks_files
|
19
|
+
return unless options[:tasks]
|
20
|
+
directory 'lib/tasks', plugin_dir('lib/tasks')
|
21
|
+
end
|
22
|
+
|
23
|
+
hook_for :generator do |generator|
|
24
|
+
inside plugin_dir, :verbose => true do
|
25
|
+
invoke generator, [ name ], :namespace => false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
hook_for :test_framework do |test_framework|
|
30
|
+
inside plugin_dir, :verbose => true do
|
31
|
+
invoke test_framework
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def plugin_dir(join=nil)
|
38
|
+
if join
|
39
|
+
File.join(plugin_dir, join)
|
40
|
+
else
|
41
|
+
"vendor/plugins/#{file_name}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) <%= Date.today.year %> [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
# Include hook code here
|
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1 @@
|
|
1
|
+
# <%= class_name %>
|
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new resource including an empty model and controller suitable
|
3
|
+
for a restful, resource-oriented application. Pass the singular model name,
|
4
|
+
either CamelCased or under_scored, as the first argument, and an optional
|
5
|
+
list of attribute pairs.
|
6
|
+
|
7
|
+
Attribute pairs are field:type arguments specifying the
|
8
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
9
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
10
|
+
|
11
|
+
You don't have to think up every attribute up front, but it helps to
|
12
|
+
sketch out a few so you can start working with the model immediately.
|
13
|
+
|
14
|
+
This generator invokes your configured ORM and test framework, besides
|
15
|
+
creating helpers and add routes to config/routes.rb.
|
16
|
+
|
17
|
+
Unlike the scaffold generator, the resource generator does not create
|
18
|
+
views or add any methods to the generated controller.
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
`./script/generate resource post` # no attributes
|
22
|
+
`./script/generate resource post title:string body:text published:boolean`
|
23
|
+
`./script/generate resource purchase order_id:integer amount:decimal`
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
require 'generators/rails/model/model_generator'
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
module Generators
|
6
|
+
class ResourceGenerator < ModelGenerator #metagenerator
|
7
|
+
include ResourceHelpers
|
8
|
+
|
9
|
+
hook_for :resource_controller, :required => true do |controller|
|
10
|
+
invoke controller, [ controller_name, options[:actions] ]
|
11
|
+
end
|
12
|
+
|
13
|
+
class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
|
14
|
+
:desc => "Actions for the resource controller"
|
15
|
+
|
16
|
+
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
|
17
|
+
|
18
|
+
def add_resource_route
|
19
|
+
route "resource#{:s unless options[:singleton]} :#{pluralize?(file_name)}"
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def pluralize?(name)
|
25
|
+
if options[:singleton]
|
26
|
+
name
|
27
|
+
else
|
28
|
+
name.pluralize
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire resource, from model and migration to controller and
|
3
|
+
views, along with a full test suite. The resource is ready to use as a
|
4
|
+
starting point for your RESTful, resource-oriented application.
|
5
|
+
|
6
|
+
Pass the name of the model (in singular form), either CamelCased or
|
7
|
+
under_scored, as the first argument, and an optional list of attribute
|
8
|
+
pairs.
|
9
|
+
|
10
|
+
Attribute pairs are field:type arguments specifying the
|
11
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
12
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
13
|
+
|
14
|
+
You don't have to think up every attribute up front, but it helps to
|
15
|
+
sketch out a few so you can start working with the resource immediately.
|
16
|
+
|
17
|
+
For example, 'scaffold post title:string body:text published:boolean'
|
18
|
+
gives you a model with those three attributes, a controller that handles
|
19
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
20
|
+
an index that lists them all, as well as a resources :posts
|
21
|
+
declaration in config/routes.rb.
|
22
|
+
|
23
|
+
If you want to remove all the generated files, run
|
24
|
+
'script/destroy scaffold ModelName'.
|
25
|
+
|
26
|
+
Examples:
|
27
|
+
`./script/generate scaffold post`
|
28
|
+
`./script/generate scaffold post title:string body:text published:boolean`
|
29
|
+
`./script/generate scaffold purchase order_id:integer amount:decimal`
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'generators/rails/resource/resource_generator'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generators
|
5
|
+
class ScaffoldGenerator < ResourceGenerator #metagenerator
|
6
|
+
remove_hook_for :resource_controller
|
7
|
+
remove_class_option :actions
|
8
|
+
|
9
|
+
hook_for :scaffold_controller, :required => true
|
10
|
+
hook_for :stylesheets
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a scaffolded controller and its views. Pass the model name,
|
3
|
+
either CamelCased or under_scored, and a list of views as arguments.
|
4
|
+
The controller name is retrieved as a pluralized version of the model
|
5
|
+
name.
|
6
|
+
|
7
|
+
To create a controller within a module, specify the model name as a
|
8
|
+
path like 'parent_module/controller_name'.
|
9
|
+
|
10
|
+
This generates a controller class in app/controllers and invokes helper,
|
11
|
+
template engine and test framework generators.
|
12
|
+
|
13
|
+
Example:
|
14
|
+
`./script/generate scaffold_controller CreditCard`
|
15
|
+
|
16
|
+
Credit card controller with URLs like /credit_card/debit.
|
17
|
+
Controller: app/controllers/credit_cards_controller.rb
|
18
|
+
Functional Test: test/functional/credit_cards_controller_test.rb
|
19
|
+
Views: app/views/credit_cards/index.html.erb [...]
|
20
|
+
Helper: app/helpers/credit_cards_helper.rb
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/generators/resource_helpers'
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
module Generators
|
5
|
+
class ScaffoldControllerGenerator < NamedBase
|
6
|
+
include ResourceHelpers
|
7
|
+
|
8
|
+
check_class_collision :suffix => "Controller"
|
9
|
+
|
10
|
+
class_option :orm, :banner => "NAME", :type => :string, :required => true,
|
11
|
+
:desc => "ORM to generate the controller for"
|
12
|
+
|
13
|
+
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
|
14
|
+
|
15
|
+
def create_controller_files
|
16
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
hook_for :template_engine, :test_framework, :as => :scaffold
|
20
|
+
|
21
|
+
# Invoke the helper using the controller name (pluralized)
|
22
|
+
hook_for :helper, :as => :scaffold do |invoked|
|
23
|
+
invoke invoked, [ controller_name ]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
<% unless options[:singleton] -%>
|
3
|
+
# GET /<%= table_name %>
|
4
|
+
# GET /<%= table_name %>.xml
|
5
|
+
def index
|
6
|
+
@<%= table_name %> = <%= orm_class.all(class_name) %>
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html # index.html.erb
|
10
|
+
format.xml { render :xml => @<%= table_name %> }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
# GET /<%= table_name %>/1
|
16
|
+
# GET /<%= table_name %>/1.xml
|
17
|
+
def show
|
18
|
+
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
format.html # show.html.erb
|
22
|
+
format.xml { render :xml => @<%= file_name %> }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# GET /<%= table_name %>/new
|
27
|
+
# GET /<%= table_name %>/new.xml
|
28
|
+
def new
|
29
|
+
@<%= file_name %> = <%= orm_class.build(class_name) %>
|
30
|
+
|
31
|
+
respond_to do |format|
|
32
|
+
format.html # new.html.erb
|
33
|
+
format.xml { render :xml => @<%= file_name %> }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# GET /<%= table_name %>/1/edit
|
38
|
+
def edit
|
39
|
+
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
40
|
+
end
|
41
|
+
|
42
|
+
# POST /<%= table_name %>
|
43
|
+
# POST /<%= table_name %>.xml
|
44
|
+
def create
|
45
|
+
@<%= file_name %> = <%= orm_class.build(class_name, "params[:#{file_name}]") %>
|
46
|
+
|
47
|
+
respond_to do |format|
|
48
|
+
if @<%= orm_instance.save %>
|
49
|
+
format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully created.') }
|
50
|
+
format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
|
51
|
+
else
|
52
|
+
format.html { render :action => "new" }
|
53
|
+
format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# PUT /<%= table_name %>/1
|
59
|
+
# PUT /<%= table_name %>/1.xml
|
60
|
+
def update
|
61
|
+
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
62
|
+
|
63
|
+
respond_to do |format|
|
64
|
+
if @<%= orm_instance.update_attributes("params[:#{file_name}]") %>
|
65
|
+
format.html { redirect_to(@<%= file_name %>, :notice => '<%= class_name %> was successfully updated.') }
|
66
|
+
format.xml { head :ok }
|
67
|
+
else
|
68
|
+
format.html { render :action => "edit" }
|
69
|
+
format.xml { render :xml => @<%= orm_instance.errors %>, :status => :unprocessable_entity }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# DELETE /<%= table_name %>/1
|
75
|
+
# DELETE /<%= table_name %>/1.xml
|
76
|
+
def destroy
|
77
|
+
@<%= file_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
78
|
+
@<%= orm_instance.destroy %>
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html { redirect_to(<%= table_name %>_url) }
|
82
|
+
format.xml { head :ok }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|