From 68dd44cc62062c8f3c82dde678bf99e8f2245bb5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 28 Feb 2010 22:28:58 +0100 Subject: AS guide: documents String#pluralize --- .../guides/source/active_support_core_extensions.textile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 278d27ec67..b3e4bc778a 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1249,6 +1249,22 @@ The call +str.last(n)+ is equivalent to +str.from(-n)+ if +n+ > 0, and returns a NOTE: Defined in +active_support/core_ext/string/access.rb+. +h4. Inflections + +h5. +pluralize+ + +The method +pluralize+ returns the plural of its receiver: + + +"table".pluralize # => "tables" +"ruby".pluralize # => "rubies" +"equipment".pluralize # => "equipment" + + +As the previous example shows, Active Support knows some irregular plurals and a few uncountable nouns. Builtin rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 947511e50e7c60d8bed581c8f20f4ebbc72a4d14 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 28 Feb 2010 22:32:00 +0100 Subject: AS guide: shortens a sentence --- railties/guides/source/active_support_core_extensions.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index b3e4bc778a..23879827e2 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1261,7 +1261,7 @@ The method +pluralize+ returns the plural of its receiver: "equipment".pluralize # => "equipment" -As the previous example shows, Active Support knows some irregular plurals and a few uncountable nouns. Builtin rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments. +As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Builtin rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments. NOTE: Defined in +active_support/core_ext/string/inflections.rb+. -- cgit v1.2.3 From 51e84bfbd6e53cef8b563bdf99ea47631bece677 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 05:35:01 +0100 Subject: AS guide: adds a real example for #pluralize --- railties/guides/source/active_support_core_extensions.textile | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 23879827e2..7ee414f34b 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1263,6 +1263,17 @@ The method +pluralize+ returns the plural of its receiver: As the previous example shows, Active Support knows some irregular plurals and uncountable nouns. Builtin rules can be extended in +config/initializers/inflections.rb+. That file is generated by the +rails+ command and has instructions in comments. +Active Record uses this method to compute the default table name that corresponds to a model: + + +# active_record/base.rb +def undecorated_table_name(class_name = base_class.name) + table_name = class_name.to_s.demodulize.underscore + table_name = table_name.pluralize if pluralize_table_names + table_name +end + + NOTE: Defined in +active_support/core_ext/string/inflections.rb+. h3. Extensions to +Numeric+ -- cgit v1.2.3 From 1064c533ceb46562da39b3b0e50709ceaf0d65d4 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 05:43:56 +0100 Subject: AS guide: documents String#singularize --- .../source/active_support_core_extensions.textile | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 7ee414f34b..c1a79189bd 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1276,6 +1276,29 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +singularize+ + +The inverse of +pluralize+: + + +"tables".singularize # => "table" +"rubies".singularize # => "ruby" +"equipment".singularize # => "equipment" + + +Associations compute the name of the corresponding default associated class using this method: + + +# active_record/reflection.rb +def derive_class_name + class_name = name.to_s.camelize + class_name = class_name.singularize if collection? + class_name +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 0f847b95ebe2d80bfe67d4f182a4458f2091f322 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 06:07:31 +0100 Subject: AS guide: documents String#underscore --- .../source/active_support_core_extensions.textile | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index c1a79189bd..51ef164d85 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1299,6 +1299,85 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +camelize+ + +The method +camelize+ returns its receiver in camel case: + + +"product".camelize # => "Product" +"admin_user".camelize # => "AdminUser" + + +As a rule of thumb you can think of this method as the one that transforms paths into Ruby class or module names, where slashes separate namespaces: + + +"backoffice/session".camelize # => "Backoffice::Session" + + +For example, Action Pack uses this method to load the class that provides a certain session store: + + +# action_controller/metal/session_management.rb +def session_store=(store) + if store == :active_record_store + self.session_store = ActiveRecord::SessionStore + else + @@session_store = store.is_a?(Symbol) ? + ActionDispatch::Session.const_get(store.to_s.camelize) : + store + end +end + + ++camelize+ accepts an optional argument, it can be +:upper+ (default), or +:lower+. With the latter the first letter becomes lowercase: + + +"visual_effect".camelize(:lower) # => "visualEffect" + + +That may be handy to compute method names in a language that follows that convention, for example JavaScript. + ++camelize+ is aliased to +camelcase+. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + +h5. +underscore+ + +The method +underscore+ is the inverse of +camelize+, explained above: + + +"Product".underscore # => "product" +"AdminUser".underscore # => "admin_user" + + +Also converts "::" back to "/": + + +"Backoffice::Session".underscore # => "backoffice/session" + + +and understands strings that start with lowercase: + + +"visualEffect".underscore # => "visual_effect" + + ++underscore+ accepts no argument though. + +Rails class and module autoloading uses +underscore+ to infer the relative path without extension of a file that would define a given missing constant: + + +# active_support/dependencies.rb +def load_missing_constant(from_mod, const_name) + ... + qualified_name = qualified_name_for from_mod, const_name + path_suffix = qualified_name.underscore + ... +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From aed8c1f0a471915bc10cf8be3244f4efa69f06b5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 22:17:12 +0100 Subject: AV guide: titleize is defined by Active Support --- railties/guides/source/action_view_overview.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 4aa43a8f3c..a517193cea 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -33,13 +33,13 @@ gem install actionpack gem install rack -Now we'll create a simple "Hello World" application that uses the +titleize+ method provided by Action View. +Now we'll create a simple "Hello World" application that uses the +titleize+ method provided by Active Support. *hello_world.rb:* require 'rubygems' -require 'action_view' +require 'active_support/core_ext/string/inflections' require 'rack' def hello_world(env) -- cgit v1.2.3 From 71990a4157f37bc7529184654265679a62a9e121 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 22:32:58 +0100 Subject: AS guide: documents String#titleize --- .../guides/source/active_support_core_extensions.textile | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 51ef164d85..5f1849f2b6 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1378,6 +1378,19 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +titleize+ + +The method +titleize+ capitalizes the words in the receiver: + + +"alice in wonderland".titleize # => "Alice In Wonderland" +"fermat's enigma".titleize # => "Fermat's Enigma" + + ++titleize+ is aliased to +titlecase+. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 44bd3bd4ff2705b798313fbbb60cb7064b328f9b Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 22:58:21 +0100 Subject: AS guide: documents String#dasherize --- .../source/active_support_core_extensions.textile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 5f1849f2b6..e56dde2977 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1391,6 +1391,27 @@ The method +titleize+ capitalizes the words in the receiver: NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +dasherize+ + +The method +dasherize+ replaces the underscores in the receiver with dashes: + + +"name".dasherize # => "name" +"contact_data".dasherize # => "contact-data" + + +The XML serializer of models uses this method to dasherize node names: + + +# active_model/serializers/xml.rb +def reformat_name(name) + name = name.camelize if camelize? + dasherize? ? name.dasherize : name +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From aab42ccdab084dbd661d3e21d9fce15d0f3f6a06 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Mon, 1 Mar 2010 23:42:12 +0100 Subject: AS guide: documents String#demodulize --- .../source/active_support_core_extensions.textile | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index e56dde2977..307f7eddb3 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1412,6 +1412,31 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +demodulize+ + +Given a string with a qualified constant reference expression, +demodulize+ returns the very constant name, that is, the rightmost part of it: + + +"Product".demodulize # => "Product" +"Backoffice::UsersController".demodulize # => "UsersController" +"Admin::Hotel::ReservationUtils".demodulize # => "ReservationUtils" + + +Active Record for example uses this method to compute the name of a counter cache column: + + +# active_record/reflection.rb +def counter_cache_column + if options[:counter_cache] == true + "#{active_record.name.demodulize.underscore.pluralize}_count" + elsif options[:counter_cache] + options[:counter_cache] + end +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From fbce2327a9d327a203bb401708b6e3a4bd023e38 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 2 Mar 2010 00:06:32 +0100 Subject: AS guide: documents String#parameterize --- .../guides/source/active_support_core_extensions.textile | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 307f7eddb3..291dc5e96a 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1437,6 +1437,19 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +parameterize+ + +The method +parameterize+ normalizes its receiver in a way that can be used in pretty URLs. + + +"John Smith".parameterize # => "john-smith" +"Kurt Gödel".parameterize # => "kurt-godel" + + +In fact, the result string is wrapped in an instance of +ActiveSupport::Multibyte::Chars+. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 88c01b3f10d8bc47359f2f69f69a606ace5fc0f6 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 2 Mar 2010 00:25:25 +0100 Subject: AS guide: documents String#tableize --- .../guides/source/active_support_core_extensions.textile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 291dc5e96a..2571c83dd8 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1450,6 +1450,20 @@ In fact, the result string is wrapped in an instance of +ActiveSupport::Multibyt NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +tableize+ + +The method +tableize+ is +underscore+ followed by +pluralize+. + + +"Person".tableize # => "people" +"Invoice".tableize # => "invoices" +"InvoiceLine".tableize # => "invoice_lines" + + +As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes de class name and checks a few options that may affect the returned string. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 3084898ca6d98d37da64705d755e189e36040339 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 2 Mar 2010 22:29:58 +0100 Subject: AS guide: documents String#classify --- .../source/active_support_core_extensions.textile | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 2571c83dd8..26e4113edf 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1457,13 +1457,33 @@ The method +tableize+ is +underscore+ followed by +pluralize+. "Person".tableize # => "people" "Invoice".tableize # => "invoices" -"InvoiceLine".tableize # => "invoice_lines" +"InvoiceLine".tableize # => "invoice_lines" As a rule of thumb, +tableize+ returns the table name that corresponds to a given model for simple cases. The actual implementation in Active Record is not straight +tableize+ indeed, because it also demodulizes de class name and checks a few options that may affect the returned string. NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +classify+ + +The method +classify+ is the inverse of +tableize+. It gives you the class name corresponding to a table name: + + +"people".classify # => "Person" +"invoices".classify # => "Invoice" +"invoice_lines".classify # => "InvoiceLine" + + +The method understands qualified table names: + + +"highrise_production.companies".classify # => "Company" + + +Note that +classify+ returns a class name as a string. You can get the actual class object invoking +constantize+ on it, explained next. + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 8627281e3b75dbafc0adee7ab4f3d28a177aa9e5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 2 Mar 2010 23:02:44 +0100 Subject: AS guide: documents String#constantize --- .../source/active_support_core_extensions.textile | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 26e4113edf..149ebefbab 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1484,6 +1484,49 @@ Note that +classify+ returns a class name as a string. You can get the actual cl NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +constantize+ + +The method +constantize+ resolves the constant reference expression in its receiver: + + +"Fixnum".constantize # => Fixnum + +module M + X = 1 +end +"M::X".constantize # => 1 + + +If the string evaluates to no known constant, or its content is not even a valid constant name, +constantize+ raises +NameError+. + +Constant name resolution by +constantize+ starts always at the top-level +Object+ even if there is no leading "::". + + +X = :in_Object +module M + X = :in_M + + X # => :in_M + "::X".constantize # => :in_Object + "X".constantize # => :in_Object (!) +end + + +So, it is in general not equivalent to what Ruby would do in the same spot, had a real constant be evaluated. + +Mailer test cases obtain the mailer being tested from the name of the test class using +constantize+: + + +# action_mailer/test_case.rb +def determine_default_mailer(name) + name.sub(/Test$/, '').constantize +rescue NameError => e + raise NonInferrableMailerError.new(name) +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 3100ec4355320c088e0969bd5caf62c5c0042f4a Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 3 Mar 2010 00:05:01 +0100 Subject: AS guide: documents String#humanize --- .../source/active_support_core_extensions.textile | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 149ebefbab..3370939861 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1527,6 +1527,35 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +humanize+ + +The method +humanize+ gives you a sensible name for display out of an attribute name. To do so it replaces underscores with spaces, removes any "_id" suffix, and capitalizes the first word: + + +"name".humanize # => "Name" +"author_id".humanize # => "Author" +"comments_count".humanize # => "Comments count" + + +The helper method +full_messages+ uses +humanize+ as a fallback to include attribute names: + + +def full_messages + full_messages = [] + + each do |attribute, messages| + ... + attr_name = attribute.to_s.gsub('.', '_').humanize + attr_name = @base.class.human_attribute_name(attribute, :default => attr_name) + ... + end + + full_messages +end + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From a368f3b170a30ac9c5f479ba6a62bc4d1b82c972 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 3 Mar 2010 00:18:57 +0100 Subject: AS guide: documents String#foreign_key --- .../source/active_support_core_extensions.textile | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 3370939861..368dcc00b6 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1556,6 +1556,31 @@ end NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +foreign_key+ + +The method +foreign_key+ gives a foreign key column name from a class name. To do so it demodulizes, underscores, and adds "_id": + + +"User".foreign_key # => "user_id" +"InvoiceLine".foreign_key # => "invoice_line_id" +"Admin::Session".foreign_key # => "session_id" + + +Pass a false argument if you do not want the underscore in "_id": + + +"User".foreign_key(false) # => "userid" + + +Associations use this method to infer foreign keys, for example +has_one+ and +has_many+ do this: + + +# active_record/associations.rb +foreign_key = options[:foreign_key] || reflection.active_record.name.foreign_key + + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes -- cgit v1.2.3 From 71b29d1e56e630bafeca5345a358b4cdbd98c6e5 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 3 Mar 2010 19:58:44 +0100 Subject: AS guide: How to Load Core Extensions --- .../source/active_support_core_extensions.textile | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 368dcc00b6..11f0bc956f 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -6,6 +6,62 @@ By referring to this guide you will learn the extensions to the Ruby core classe endprologue. +h3. How to Load Core Extensions + +In order to have a near zero default footprint, Active Support does not load anything by default. It is broken in small pieces so that you may load just what you need, and also has some convenience entry points to load related extensions in one shot, even everything. + +Thus, after a simple require like: + + +require 'active_support' + + +objects do not even respond to +blank?+, let's see how to load its definition. + +h4. Cherry-picking a Definition + +The most lightweight way to get +blank?+ is to cherry-pick the file that defines it. + +For every single method defined as a core extension this guide has a note that says where is such a method defined. In the case of +blank?+ the note reads: + +NOTE: Defined in +active_support/core_ext/object/blank.rb+. + +That means that this single call is enough: + + +require 'active_support/core_ext/object/blank' + + +Active Support has been carefully revised so that cherry-picking a file loads only strictly needed dependencies, if any. + +h4. Loading Grouped Core Extensions + +The next level is to simply load all extensions to +Object+. As a rule of thumb, extensions to +SomeClass+ are available in one shot by loading +active_support/core_ext/some_class+. + +Thus, if that would do, to have +blank?+ available we could just load all extensions to +Object+: + + +require 'active_support/core_ext/object' + + +h4. Loading All Core Extensions + +You may prefer just to load all core extensions, there is a file for that: + + +require 'active_support/core_ext' + + +h4. Loading All Active Support + +And finally, if you want to have all Active Support available just issue: + + +require 'active_support/all' + + +That does not even put the entire Active Support in memory upfront indeed, some stuff is configured via +autoload+, so it is only loaded if used. + h3. Extensions to All Objects h4. +blank?+ and +present?+ -- cgit v1.2.3 From dca6ddea043d79d9a1b0577bc1b8e2a93c96d555 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Thu, 4 Mar 2010 01:42:57 +0100 Subject: the guides generator needs fileutils --- railties/guides/rails_guides/generator.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties/guides') diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index 2f0718af75..7c8d26a1ea 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -1,4 +1,5 @@ require 'set' +require 'fileutils' module RailsGuides class Generator -- cgit v1.2.3 From 5245bf86353043050f569446333cf77faa8c5326 Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Thu, 4 Mar 2010 01:48:56 +0100 Subject: Updated 3_0_release_notes so that it specifies that the rack-mount gem needs to be version 0.4 --- railties/guides/source/3_0_release_notes.textile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index 4bee0f537f..73479b3c0f 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -25,8 +25,9 @@ TIP: To install the Rails 3 prerelease beta using rubygems you have to install a # Use sudo if your setup requires it gem install tzinfo builder i18n memcache-client rack \ - rake rack-test rack-mount erubis mail text-format \ + rake rack-test erubis mail text-format \ thor bundler +gem install rack-mount -v=0.4 gem install rails --pre -- cgit v1.2.3 From 36d28f5168000b250fc87c88eef20294e059096d Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Thu, 4 Mar 2010 01:51:25 +0100 Subject: Update contribute guide so that it shows the new command to generate guides (rake generate_guides instead of rake guides) --- railties/guides/source/contribute.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/contribute.textile b/railties/guides/source/contribute.textile index 5087c2f385..a48edef79d 100644 --- a/railties/guides/source/contribute.textile +++ b/railties/guides/source/contribute.textile @@ -12,7 +12,7 @@ h3. How to Contribute? * All images are in the railties/guides/images directory. * Sample format : "Active Record Associations":http://github.com/lifo/docrails/blob/3e56a3832415476fdd1cb963980d0ae390ac1ed3/railties/guides/source/association_basics.textile * Sample output : "Active Record Associations":http://guides.rails.info/association_basics.html -* You can build the Guides during testing by running +rake guides+ in the +railties+ directory. +* You can build the Guides during testing by running +rake generate_guides+ in the +railties+ directory. h3. What to Contribute? -- cgit v1.2.3