From afc102698672cdf546a15424471d3287a39dbb06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 2 Jun 2010 08:45:03 +0200 Subject: Still copy application configuration to generator even if they are required earlier. Also tidy up the guide a little bit. --- railties/guides/source/generators.textile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index d3757e9733..b77a2837c3 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -322,14 +322,10 @@ config.generators do |g| g.template_engine :erb g.test_framework :shoulda, :fixture => false g.stylesheets false -end - - -And at the end of the same file: - -require 'rails/generators' -Rails::Generators.fallbacks[:shoulda] = :test_unit + # Add a fallback! + g.fallbacks[:should] = :test_unit +end Now, if create a Comment scaffold, you will see that shoulda generators are being invoked, and at the end, they are just falling back to test unit generators: @@ -361,7 +357,7 @@ $ rails generate scaffold Comment body:text create test/unit/helpers/comments_helper_test.rb -Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of code duplication. +Such tool allows your generators to have single responsibility, increasing the code reuse and reducing the amount of duplication. h3. Changelog -- cgit v1.2.3 From bf83c5709f212b25575249bc7e1b6d7f7a0ad085 Mon Sep 17 00:00:00 2001 From: Mikel Lindsaar Date: Fri, 4 Jun 2010 00:03:42 +1000 Subject: Updating guides to new rails initialization process Signed-off-by: David Heinemeier Hansson --- railties/guides/source/3_0_release_notes.textile | 6 +++--- railties/guides/source/generators.textile | 2 +- railties/guides/source/getting_started.textile | 2 +- railties/guides/source/rails_application_templates.textile | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index b7f4fbf35c..2a8d7fbcdb 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -81,7 +81,7 @@ The new installing rails sequence (for the beta) is: $ gem install rails --prerelease -$ rails myapp +$ rails new myapp $ cd myapp @@ -98,13 +98,13 @@ h4. Living on the Edge If you want to bundle straight from the Git repository, you can pass the +--edge+ flag: -$ rails myapp --edge +$ rails new myapp --edge If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the +--dev+ flag: -$ ruby /path/to/rails/bin/rails myapp --dev +$ ruby /path/to/rails/bin/rails new myapp --dev h3. Rails Architectural Changes diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index b77a2837c3..704a8793b2 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -20,7 +20,7 @@ h3. First contact When you create an application using the +rails+ command, you are in fact using a Rails generator. After that, you can get a list of all available generators by just invoking +rails generate+: -$ rails myapp +$ rails new myapp $ cd myapp $ rails generate diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 46e709d0f5..89551a223d 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -160,7 +160,7 @@ The best way to use this guide is to follow each step as it happens, no code or To begin, open a terminal, navigate to a folder where you have rights to create files, and type: -$ rails blog +$ rails new blog This will create a Rails application called Blog in a directory called blog. diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile index baaa3d6d66..1af6f56957 100644 --- a/railties/guides/source/rails_application_templates.textile +++ b/railties/guides/source/rails_application_templates.textile @@ -14,13 +14,13 @@ h3. Usage To apply a template, you need to provide the Rails generator with the location of the template you wish to apply, using -m option : -$ rails blog -m ~/template.rb +$ rails new blog -m ~/template.rb It's also possible to apply a template using a URL : -$ rails blog -m http://gist.github.com/31208.txt +$ rails new blog -m http://gist.github.com/31208.txt Alternatively, you can use the rake task +rails:template+ to apply a template to an existing Rails application : -- cgit v1.2.3 From 67a43554f153a3ddb97039b5fac305c0619dd372 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 5 Jun 2010 01:13:37 +0200 Subject: removes Array#random_element and backports Array#sample from Ruby 1.9, thanks to Marc-Andre Lafortune --- railties/guides/source/3_0_release_notes.textile | 1 + .../guides/source/active_support_core_extensions.textile | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index 2a8d7fbcdb..75c03be87c 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -512,6 +512,7 @@ These are the main changes in Active Support: * Active Support no longer provides vendored versions of "TZInfo":http://tzinfo.rubyforge.org/, "Memcache Client":http://deveiate.org/projects/RMemCache/ and "Builder":http://builder.rubyforge.org/, these are all included as dependencies and installed via the bundle install command. * Safe buffers are implemented in ActiveSupport::SafeBuffer. * Added Array.uniq_by and Array.uniq_by!. +* Removed Array#rand and backported Array#sample from Ruby 1.9. * Fixed bug on +TimeZone.seconds_to_utc_offset+ returning wrong value. * Added ActiveSupport::Notifications middleware. * ActiveSupport.use_standard_json_time_format now defaults to true. diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index de82e871a6..6c3a005daf 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1927,13 +1927,23 @@ Similarly, +from+ returns the tail from the element at the passed index on: The methods +second+, +third+, +fourth+, and +fifth+ return the corresponding element (+first+ is builtin). Thanks to social wisdom and positive constructiveness all around, +forty_two+ is also available. -You can pick a random element with +random_element+: +NOTE: Defined in +active_support/core_ext/array/access.rb+. + +h4. Random Access + +Active Support backports +sample+ from Ruby 1.9: + +You can pick a random element with +sample+: -shape_type = [Circle, Square, Triangle].random_element +shape_type = [Circle, Square, Triangle].sample +# => Square, for example + +shape_types = [Circle, Square, Triangle].sample(2) +# => [Triangle, Circle], for example -NOTE: Defined in +active_support/core_ext/array/access.rb+. +NOTE: Defined in +active_support/core_ext/array/random_access.rb+. h4. Options Extraction -- cgit v1.2.3 From 8e8cb1769f3a78c53e5b79d0ce6a08589045cfca Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 5 Jun 2010 01:19:23 +0200 Subject: AS guide: removes your spurious line --- railties/guides/source/active_support_core_extensions.textile | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 6c3a005daf..30b2099be4 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1933,8 +1933,6 @@ h4. Random Access Active Support backports +sample+ from Ruby 1.9: -You can pick a random element with +sample+: - shape_type = [Circle, Square, Triangle].sample # => Square, for example -- cgit v1.2.3