From 7531aa76417a5db337287c31c1b97ad53615c8e6 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Thu, 15 Sep 2011 10:41:55 +0400 Subject: update guides, use html safe translations in i18n --- .../guides/assets/images/i18n/demo_html_safe.png | Bin 0 -> 11946 bytes railties/guides/source/i18n.textile | 22 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 railties/guides/assets/images/i18n/demo_html_safe.png diff --git a/railties/guides/assets/images/i18n/demo_html_safe.png b/railties/guides/assets/images/i18n/demo_html_safe.png new file mode 100644 index 0000000000..f881f60dac Binary files /dev/null and b/railties/guides/assets/images/i18n/demo_html_safe.png differ diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 4b6b08bcec..76cd14d479 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -448,6 +448,7 @@ Covered are features like these: * looking up translations * interpolating data into translations * pluralizing translations +* using safe HTML translations * localizing dates, numbers, currency, etc. h4. Looking up Translations @@ -599,6 +600,27 @@ The +I18n.locale+ defaults to +I18n.default_locale+ which defaults to :+en+. The I18n.default_locale = :de +h4. Using Safe HTML Translations + +Keys with a '_html' suffix and keys named 'html' are marked as HTML safe. Use them in views without escaping. + + +# config/locales/en.yml +en: + welcome: welcome! + hello_html: hello! + title: + html: title! + +# app/views/home/index.html.erb +
<%= t('welcome') %>
+
<%= raw t('welcome') %>
+
<%= t('hello_html') %>
+
<%= t('title.html') %>
+
+ +!images/i18n/demo_html_safe.png(i18n demo html safe)! + h3. How to Store your Custom Translations The Simple backend shipped with Active Support allows you to store translations in both plain Ruby and YAML format. [2] -- cgit v1.2.3 From 28677014a4f8121272a17870246507e86e46837c Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Thu, 15 Sep 2011 20:07:01 -0500 Subject: Add reference about --skip-sprockets to Asset Pipeline Guide --- railties/guides/source/asset_pipeline.textile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index ce4eafb97c..74dfdfb540 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -25,6 +25,12 @@ In Rails 3.1, the asset pipeline is enabled by default. It can be disabled in +a config.assets.enabled = false +You can also disable it when you are creating a new application passing the --skip-sprockets parameter: + + +rails new appname --skip-sprockets + + It is recommended that you use the defaults for all new apps. -- cgit v1.2.3 From 302e570777b1ca8f537c96628334dcbe8a94d83f Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Fri, 16 Sep 2011 17:43:05 +0400 Subject: "Passing variables into the translation" section added --- railties/guides/source/i18n.textile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 76cd14d479..a35cd6c506 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -365,6 +365,20 @@ NOTE: You need to restart the server when you add new locale files. You may use YAML (+.yml+) or plain Ruby (+.rb+) files for storing your translations in SimpleStore. YAML is the preferred option among Rails developers. However, it has one big disadvantage. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. Ruby files will crash your application on first request, so you may easily find what's wrong. (If you encounter any "weird issues" with YAML dictionaries, try putting the relevant portion of your dictionary into a Ruby file.) +h4. Passing variables into the translation + +You may use translation with parameters, if you want. + + +# app/views/home/index.html.erb +

<%=t 'greet_username', :user => "Bill", :message => "Goodbye" %>

+

<%=t 'greet_username', :user => "DHH", :message => "Hello" %>

+ +# config/locales/en.yml +en: + greet_username: "%{message}, %{user}!" +
+ h4. Adding Date/Time Formats OK! Now let's add a timestamp to the view, so we can demo the *date/time localization* feature as well. To localize the time format you pass the Time object to +I18n.l+ or (preferably) use Rails' +#l+ helper. You can pick a format by passing the +:format+ option -- by default the +:default+ format is used. -- cgit v1.2.3 From 8411f631c42de7d6f51d10d997b037b9eff0d1f1 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 16 Sep 2011 23:22:03 +0530 Subject: minor edit --- railties/guides/source/asset_pipeline.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index 74dfdfb540..bea5e494d5 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -25,7 +25,7 @@ In Rails 3.1, the asset pipeline is enabled by default. It can be disabled in +a config.assets.enabled = false -You can also disable it when you are creating a new application passing the --skip-sprockets parameter: +You can also disable it while creating a new application by passing the --skip-sprockets option. rails new appname --skip-sprockets -- cgit v1.2.3 From 27f1320fde03279c575693f504897f1a6171bc59 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Fri, 16 Sep 2011 22:12:41 +0530 Subject: Fixing incorrect notextile tags --- .../guides/source/action_view_overview.textile | 2 +- .../active_record_validations_callbacks.textile | 4 ++-- .../source/active_support_core_extensions.textile | 26 +++++++++++----------- railties/guides/source/ajax_on_rails.textile | 4 +++- .../source/api_documentation_guidelines.textile | 2 +- railties/guides/source/asset_pipeline.textile | 2 +- railties/guides/source/initialization.textile | 2 +- .../source/ruby_on_rails_guides_guidelines.textile | 2 +- railties/guides/source/security.textile | 6 ++--- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile index 87250c684b..40cde6ad84 100644 --- a/railties/guides/source/action_view_overview.textile +++ b/railties/guides/source/action_view_overview.textile @@ -898,7 +898,7 @@ h5. select_year Returns a select tag with options for each of the five years on each side of the current, which is selected. The five year radius can be changed using the +:start_year+ and +:end_year+ keys in the +options+. -# Generates a select field for five years on either side of +Date.today+ that defaults to the current year +# Generates a select field for five years on either side of Date.today that defaults to the current year select_year(Date.today) # Generates a select field from 1900 to 2009 that defaults to the current year diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile index 20f5e52891..5c3aae2955 100644 --- a/railties/guides/source/active_record_validations_callbacks.textile +++ b/railties/guides/source/active_record_validations_callbacks.textile @@ -328,7 +328,7 @@ This helper validates that your attributes have only numeric values. By default, If you set +:only_integer+ to +true+, then it will use the -/\A[+-]?\d+\Z/ +/\A[-]?\d\Z/ regular expression to validate the attribute's value. Otherwise, it will try to convert the value to a number using +Float+. @@ -597,7 +597,7 @@ The easiest way to add custom validators for validating individual attributes is class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) - unless value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i + unless value =~ /\A([^@\s])@((?:[-a-z0-9]\.)+[a-z]{2,})\z/i record.errors[attribute] << (options[:message] || "is not an email") end end diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index d006cc9214..b3d8760a73 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -296,7 +296,7 @@ This method escapes whatever is needed, both for the key and the value: account.to_query('company[name]') -# => "company%5Bname%5D=Johnson+%26+Johnson" +# => "company%5Bname%5D=Johnson%26Johnson" so its output is ready to be used in a query string. @@ -3385,11 +3385,11 @@ They are analogous. Please refer to their documentation above and take into acco Time.zone_default # => # -# In Barcelona, 2010/03/28 02:00 +0100 becomes 2010/03/28 03:00 +0200 due to DST. +# In Barcelona, 2010/03/28 02:00 0100 becomes 2010/03/28 03:00 0200 due to DST. t = Time.local_time(2010, 3, 28, 1, 59, 59) -# => Sun Mar 28 01:59:59 +0100 2010 +# => Sun Mar 28 01:59:59 0100 2010 t.advance(:seconds => 1) -# => Sun Mar 28 03:00:00 +0200 2010 +# => Sun Mar 28 03:00:00 0200 2010 * If +since+ or +ago+ jump to a time that can't be expressed with +Time+ a +DateTime+ object is returned instead. @@ -3406,24 +3406,24 @@ The method +all_day+ returns a range representing the whole day of the current t now = Time.current -# => Mon, 09 Aug 2010 23:20:05 UTC +00:00 +# => Mon, 09 Aug 2010 23:20:05 UTC 00:00 now.all_day -# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Mon, 09 Aug 2010 23:59:59 UTC +00:00 +# => Mon, 09 Aug 2010 00:00:00 UTC 00:00..Mon, 09 Aug 2010 23:59:59 UTC 00:00 Analogously, +all_week+, +all_month+, +all_quarter+ and +all_year+ all serve the purpose of generating time ranges. now = Time.current -# => Mon, 09 Aug 2010 23:20:05 UTC +00:00 +# => Mon, 09 Aug 2010 23:20:05 UTC 00:00 now.all_week -# => Mon, 09 Aug 2010 00:00:00 UTC +00:00..Sun, 15 Aug 2010 23:59:59 UTC +00:00 +# => Mon, 09 Aug 2010 00:00:00 UTC 00:00..Sun, 15 Aug 2010 23:59:59 UTC 00:00 now.all_month -# => Sat, 01 Aug 2010 00:00:00 UTC +00:00..Tue, 31 Aug 2010 23:59:59 UTC +00:00 +# => Sat, 01 Aug 2010 00:00:00 UTC 00:00..Tue, 31 Aug 2010 23:59:59 UTC 00:00 now.all_quarter -# => Thu, 01 Jul 2010 00:00:00 UTC +00:00..Thu, 30 Sep 2010 23:59:59 UTC +00:00 +# => Thu, 01 Jul 2010 00:00:00 UTC 00:00..Thu, 30 Sep 2010 23:59:59 UTC 00:00 now.all_year -# => Fri, 01 Jan 2010 00:00:00 UTC +00:00..Fri, 31 Dec 2010 23:59:59 UTC +00:00 +# => Fri, 01 Jan 2010 00:00:00 UTC 00:00..Fri, 31 Dec 2010 23:59:59 UTC 00:00 h4. Time Constructors @@ -3434,7 +3434,7 @@ Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user ti Time.zone_default # => # Time.current -# => Fri, 06 Aug 2010 17:11:58 CEST +02:00 +# => Fri, 06 Aug 2010 17:11:58 CEST 02:00 Analogously to +DateTime+, the predicates +past?+, and +future?+ are relative to +Time.current+. @@ -3445,7 +3445,7 @@ Use the +local_time+ class method to create time objects honoring the user time Time.zone_default # => # Time.local_time(2010, 8, 15) -# => Sun Aug 15 00:00:00 +0200 2010 +# => Sun Aug 15 00:00:00 0200 2010 The +utc_time+ class method returns a time in UTC: diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile index 77f7661deb..29d4fae888 100644 --- a/railties/guides/source/ajax_on_rails.textile +++ b/railties/guides/source/ajax_on_rails.textile @@ -104,7 +104,7 @@ Note that if we wouldn't override the default behavior (POST), the above snippet link_to_remote "Update record", :url => record_url(record), :method => :put, - :with => "'status=' + 'encodeURIComponent($('status').value) + '&completed=' + $('completed')" + :with => "'status=' 'encodeURIComponent($('status').value) '&completed=' $('completed')" This generates a remote link which adds 2 parameters to the standard URL generated by Rails, taken from the page (contained in the elements matched by the 'status' and 'completed' DOM id). @@ -124,6 +124,7 @@ link_to_remote "Add new item", 404 => "alert('Item not found!')" Let's see a typical example for the most frequent callbacks, +:success+, +:failure+ and +:complete+ in action: + link_to_remote "Add new item", :url => items_url, @@ -133,6 +134,7 @@ link_to_remote "Add new item", :success => "display_item_added(request)", :failure => "display_error(request)" + ** *:type* If you want to fire a synchronous request for some obscure reason (blocking the browser while the request is processed and doesn't return a status code), you can use the +:type+ option with the value of +:synchronous+. * Finally, using the +html_options+ parameter you can add HTML attributes to the generated tag. It works like the same parameter of the +link_to+ helper. There are interesting side effects for the +href+ and +onclick+ parameters though: ** If you specify the +href+ parameter, the AJAX link will degrade gracefully, i.e. the link will point to the URL even if JavaScript is disabled in the client browser diff --git a/railties/guides/source/api_documentation_guidelines.textile b/railties/guides/source/api_documentation_guidelines.textile index c0f709eda8..99eb668513 100644 --- a/railties/guides/source/api_documentation_guidelines.textile +++ b/railties/guides/source/api_documentation_guidelines.textile @@ -146,7 +146,7 @@ h3. Description Lists In lists of options, parameters, etc. use a hyphen between the item and its description (reads better than a colon because normally options are symbols): -# * :allow_nil - Skip validation if attribute is +nil+. +# * :allow_nil - Skip validation if attribute is nil. The description starts in upper case and ends with a full stop—it's standard English. diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index bea5e494d5..e03ae736a8 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -359,7 +359,7 @@ NOTE. If you are precompiling your assets locally, you can use +bundle install - The default matcher for compiling files includes +application.js+, +application.css+ and all files that do not end in +js+ or +css+: -[ /\w+\.(?!js|css).+/, /application.(css|js)$/ ] +[ /\w\.(?!js|css)./, /application.(css|js)$/ ] If you have other manifests or individual stylesheets and JavaScript files to include, you can add them to the +precompile+ array: diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile index 8aabc3ae91..32b41fdd2c 100644 --- a/railties/guides/source/initialization.textile +++ b/railties/guides/source/initialization.textile @@ -450,7 +450,7 @@ run YourApp::Application The +Rack::Builder.parse_file+ method here takes the content from this +config.ru+ file and parses it using this code: -app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app", +app = eval "Rack::Builder.new {( " cfgfile "\n )}.to_app", TOPLEVEL_BINDING, config diff --git a/railties/guides/source/ruby_on_rails_guides_guidelines.textile b/railties/guides/source/ruby_on_rails_guides_guidelines.textile index e63f564c83..29aefd25f8 100644 --- a/railties/guides/source/ruby_on_rails_guides_guidelines.textile +++ b/railties/guides/source/ruby_on_rails_guides_guidelines.textile @@ -26,7 +26,7 @@ h5. When are Objects Saved? Use the same typography as in regular text: -h6. The +:content_type+ Option +h6. The :content_type Option h3. API Documentation Guidelines diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile index 4cf9e2a7f3..73c7a80ff6 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -582,7 +582,7 @@ Ruby uses a slightly different approach than many other languages to match the e class File < ActiveRecord::Base - validates :name, :format => /^[\w\.\-\+]+$/ + validates :name, :format => /^[\w\.\-\]$/ end @@ -595,7 +595,7 @@ file.txt%0A Whereas %0A is a line feed in URL encoding, so Rails automatically converts it to "file.txt\n<script>alert('hello')</script>". This file name passes the filter because the regular expression matches – up to the line end, the rest does not matter. The correct expression should read: -/\A[\w\.\-\+]+\z/ +/\A[\w\.\-\]\z/ h4. Privilege Escalation @@ -762,7 +762,7 @@ These examples don't do any harm so far, so let's see how an attacker can steal For an attacker, of course, this is not useful, as the victim will see his own cookie. The next example will try to load an image from the URL http://www.attacker.com/ plus the cookie. Of course this URL does not exist, so the browser displays nothing. But the attacker can review his web server's access log files to see the victim's cookie. - + The log files on www.attacker.com will read like this: -- cgit v1.2.3 From 663031801cac577a88931cdfe6f062555112f370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Sat, 17 Sep 2011 10:00:53 +0300 Subject: sass-rails helpers - hyphenated in Sass, underscored in Ruby. --- railties/guides/source/asset_pipeline.textile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/railties/guides/source/asset_pipeline.textile b/railties/guides/source/asset_pipeline.textile index e03ae736a8..586a9f46eb 100644 --- a/railties/guides/source/asset_pipeline.textile +++ b/railties/guides/source/asset_pipeline.textile @@ -170,15 +170,15 @@ Note that the closing tag cannot be of the style +-%>+. h5. CSS and Sass -When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +_url+ and +_path+ helpers for the following asset classes: image, font, video, audio, JavaScript and stylesheet. +When using the asset pipeline, paths to assets must be re-written and +sass-rails+ provides +-url+ and +-path+ helpers (hyphenated in Sass, underscored in Ruby) for the following asset classes: image, font, video, audio, JavaScript and stylesheet. -* +image_url("rails.png")+ becomes +url(/assets/rails.png)+. -* +image_path("rails.png")+ becomes +"/assets/rails.png"+. +* +image-url("rails.png")+ becomes +url(/assets/rails.png)+ +* +image-path("rails.png")+ becomes +"/assets/rails.png"+. The more generic form can also be used but the asset path and class must both be specified: -* +asset_url("rails.png", image)+ becomes +url(/assets/rails.png)+. -* +asset_path("rails.png", image)+ becomes +"/assets/rails.png"+. +* +asset-url("rails.png", image)+ becomes +url(/assets/rails.png)+ +* +asset-path("rails.png", image)+ becomes +"/assets/rails.png"+ h5. JavaScript/CoffeeScript and ERB -- cgit v1.2.3 From 908f2616d5c2b9e26eb180859f7df529a7a59f08 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 14 Sep 2011 18:53:08 +1000 Subject: Document ActiveRecord::QueryMethods#select --- .../lib/active_record/relation/query_methods.rb | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index a11b7a3864..4468a38ee6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -37,6 +37,35 @@ module ActiveRecord relation end + # Works in two unique ways. + # + # First: takes a block so it can be used just like Array#select. + # + # Model.scoped.select { |m| m.field == value } + # + # This will build an array of objects from the database for the scope, + # converting them into an array and iterating through them using Array#select. + # + # Second: Modifies the SELECT statement for the query so that only certain + # fields are retreived: + # + # >> Model.select(:field) + # => [#] + # + # Although in the above example it looks as though this method returns an + # array, in actual fact it returns a relation object and can have other query + # methods appended to it, such as the other methods in ActiveRecord::QueryMethods. + # + # This method will also take multiple parameters: + # + # >> Model.select(:field, :other_field, :and_one_more) + # => [#] + # + # Any attributes that do not have fields retreived by a select + # will return `nil` when the getter method for that attribute is used: + # + # >> Model.select(:field).first.other_field + # => nil def select(value = Proc.new) if block_given? to_a.select {|*block_args| value.call(*block_args) } -- cgit v1.2.3 From ea29968bcfa455d9bef8c41436b6bea669dfc06d Mon Sep 17 00:00:00 2001 From: Jan Vlnas Date: Sun, 18 Sep 2011 16:41:21 +0300 Subject: Locale code for Czech is ":cs" --- railties/guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index a35cd6c506..14ce6a19d5 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -91,7 +91,7 @@ This means, that in the +:en+ locale, the key _hello_ will map to the _Hello wor The I18n library will use *English* as a *default locale*, i.e. if you don't set a different locale, +:en+ will be used for looking up translations. -NOTE: The i18n library takes a *pragmatic approach* to locale keys (after "some discussion":http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en), including only the _locale_ ("language") part, like +:en+, +:pl+, not the _region_ part, like +:en-US+ or +:en-UK+, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as +:cz+, +:th+ or +:es+ (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the +:en-US+ locale you would have $ as a currency symbol, while in +:en-UK+, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a +:en-UK+ dictionary. Various "Rails I18n plugins":http://rails-i18n.org/wiki such as "Globalize2":https://github.com/joshmh/globalize2/tree/master may help you implement it. +NOTE: The i18n library takes a *pragmatic approach* to locale keys (after "some discussion":http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en), including only the _locale_ ("language") part, like +:en+, +:pl+, not the _region_ part, like +:en-US+ or +:en-UK+, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as +:cs+, +:th+ or +:es+ (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the +:en-US+ locale you would have $ as a currency symbol, while in +:en-UK+, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a +:en-UK+ dictionary. Various "Rails I18n plugins":http://rails-i18n.org/wiki such as "Globalize2":https://github.com/joshmh/globalize2/tree/master may help you implement it. The *translations load path* (+I18n.load_path+) is just a Ruby Array of paths to your translation files that will be loaded automatically and available in your application. You can pick whatever directory and translation file naming scheme makes sense for you. -- cgit v1.2.3 From 7ed97bc8149f745317a897304c8c86f0e3bba4d2 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 20 Sep 2011 19:33:01 +0530 Subject: remove unnecessary markup --- .../guides/source/active_support_core_extensions.textile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index b3d8760a73..e81fe13010 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -3387,9 +3387,9 @@ Time.zone_default # In Barcelona, 2010/03/28 02:00 0100 becomes 2010/03/28 03:00 0200 due to DST. t = Time.local_time(2010, 3, 28, 1, 59, 59) -# => Sun Mar 28 01:59:59 0100 2010 +# => Sun Mar 28 01:59:59 +0100 2010 t.advance(:seconds => 1) -# => Sun Mar 28 03:00:00 0200 2010 +# => Sun Mar 28 03:00:00 +0200 2010 * If +since+ or +ago+ jump to a time that can't be expressed with +Time+ a +DateTime+ object is returned instead. @@ -3406,7 +3406,7 @@ The method +all_day+ returns a range representing the whole day of the current t now = Time.current -# => Mon, 09 Aug 2010 23:20:05 UTC 00:00 +# => Mon, 09 Aug 2010 23:20:05 UTC +00:00 now.all_day # => Mon, 09 Aug 2010 00:00:00 UTC 00:00..Mon, 09 Aug 2010 23:59:59 UTC 00:00 @@ -3415,7 +3415,7 @@ Analogously, +all_week+, +all_month+, +all_quarter+ and +all_year+ all serve the now = Time.current -# => Mon, 09 Aug 2010 23:20:05 UTC 00:00 +# => Mon, 09 Aug 2010 23:20:05 UTC +00:00 now.all_week # => Mon, 09 Aug 2010 00:00:00 UTC 00:00..Sun, 15 Aug 2010 23:59:59 UTC 00:00 now.all_month @@ -3434,7 +3434,7 @@ Active Support defines +Time.current+ to be +Time.zone.now+ if there's a user ti Time.zone_default # => # Time.current -# => Fri, 06 Aug 2010 17:11:58 CEST 02:00 +# => Fri, 06 Aug 2010 17:11:58 CEST +02:00 Analogously to +DateTime+, the predicates +past?+, and +future?+ are relative to +Time.current+. @@ -3445,7 +3445,7 @@ Use the +local_time+ class method to create time objects honoring the user time Time.zone_default # => # Time.local_time(2010, 8, 15) -# => Sun Aug 15 00:00:00 0200 2010 +# => Sun Aug 15 00:00:00 +0200 2010 The +utc_time+ class method returns a time in UTC: -- cgit v1.2.3 From ed1ada84ac5b443ef979c14a4d0f1a8a57fe9ab9 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 20 Sep 2011 19:39:46 +0530 Subject: copy edits 908f2616 --- activerecord/lib/active_record/relation/query_methods.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 4468a38ee6..670ba0987d 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -47,21 +47,21 @@ module ActiveRecord # converting them into an array and iterating through them using Array#select. # # Second: Modifies the SELECT statement for the query so that only certain - # fields are retreived: + # fields are retrieved: # # >> Model.select(:field) # => [#] # # Although in the above example it looks as though this method returns an - # array, in actual fact it returns a relation object and can have other query + # array, it actually returns a relation object and can have other query # methods appended to it, such as the other methods in ActiveRecord::QueryMethods. # # This method will also take multiple parameters: # # >> Model.select(:field, :other_field, :and_one_more) - # => [#] + # => [#] # - # Any attributes that do not have fields retreived by a select + # Any attributes that do not have fields retrieved by a select # will return `nil` when the getter method for that attribute is used: # # >> Model.select(:field).first.other_field -- cgit v1.2.3 From 5684ecf74966d81e6fa7193689881b5243cbbc39 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Tue, 20 Sep 2011 19:47:33 +0530 Subject: copy edits 302e5707 --- railties/guides/source/i18n.textile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 14ce6a19d5..11e1473ba2 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -365,14 +365,13 @@ NOTE: You need to restart the server when you add new locale files. You may use YAML (+.yml+) or plain Ruby (+.rb+) files for storing your translations in SimpleStore. YAML is the preferred option among Rails developers. However, it has one big disadvantage. YAML is very sensitive to whitespace and special characters, so the application may not load your dictionary properly. Ruby files will crash your application on first request, so you may easily find what's wrong. (If you encounter any "weird issues" with YAML dictionaries, try putting the relevant portion of your dictionary into a Ruby file.) -h4. Passing variables into the translation +h4. Passing variables to translations -You may use translation with parameters, if you want. +You can use variables in the translation messages and pass their values from the view. # app/views/home/index.html.erb -

<%=t 'greet_username', :user => "Bill", :message => "Goodbye" %>

-

<%=t 'greet_username', :user => "DHH", :message => "Hello" %>

+<%=t 'greet_username', :user => "Bill", :message => "Goodbye" %> # config/locales/en.yml en: -- cgit v1.2.3 From 952bccd1abe142c214605897a14682ae29a16adc Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Wed, 21 Sep 2011 01:23:58 -0700 Subject: add "the" to mirror the structure of the other two points --- railties/README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/README.rdoc b/railties/README.rdoc index 501541eb06..95c43045b0 100644 --- a/railties/README.rdoc +++ b/railties/README.rdoc @@ -6,7 +6,7 @@ Railties is responsible for gluing all frameworks together. Overall, it: * manages the +rails+ command line interface; -* and provides Rails generators core. +* and provides the Rails generators core. == Download -- cgit v1.2.3 From 564d7edf690ab60e439df7d7dfebc5144d8d1867 Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Wed, 21 Sep 2011 01:28:59 -0700 Subject: add a '.' to etc --- railties/guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 11e1473ba2..81d2ba9a56 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -12,7 +12,7 @@ So, in the process of _internationalizing_ your Rails application you have to: In the process of _localizing_ your application you'll probably want to do the following three things: -* Replace or supplement Rails' default locale -- e.g. date and time formats, month names, Active Record model names, etc +* Replace or supplement Rails' default locale -- e.g. date and time formats, month names, Active Record model names, etc. * Abstract strings in your application into keyed dictionaries -- e.g. flash messages, static text in your views, etc. * Store the resulting dictionaries somewhere -- cgit v1.2.3 From 3c5340ec9cbf12d19e734289ba748186af492d60 Mon Sep 17 00:00:00 2001 From: Waynn Lue Date: Wed, 21 Sep 2011 02:10:07 -0700 Subject: add a missing "on" and remove the "endprologue" text --- railties/guides/source/i18n.textile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 81d2ba9a56..46f6942d02 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -16,9 +16,7 @@ In the process of _localizing_ your application you'll probably want to do the f * Abstract strings in your application into keyed dictionaries -- e.g. flash messages, static text in your views, etc. * Store the resulting dictionaries somewhere -This guide will walk you through the I18n API and contains a tutorial how to internationalize a Rails application from the start. - -endprologue. +This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start. NOTE: The Ruby I18n framework provides you with all necessary means for internationalization/localization of your Rails application. You may, however, use any of various plugins and extensions available, which add additional functionality or features. See the Rails "I18n Wiki":http://rails-i18n.org/wiki for more information. -- cgit v1.2.3 From 8d7aee71738fbf1ff090ff44a09624e592b94b04 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 21 Sep 2011 02:19:44 +0530 Subject: indentation fixes --- railties/guides/source/active_support_core_extensions.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index e81fe13010..5aee001545 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -3518,8 +3518,8 @@ h4. +around_[level]+ Takes two arguments, a +before_message+ and +after_message+ and calls the current level method on the +Logger+ instance, passing in the +before_message+, then the specified message, then the +after_message+: - logger = Logger.new("log/development.log") - logger.around_info("before", "after") { |logger| logger.info("during") } +logger = Logger.new("log/development.log") +logger.around_info("before", "after") { |logger| logger.info("during") } h4. +silence+ -- cgit v1.2.3 From 3e80462b95808457eb1584195909e26887a1a40d Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 21 Sep 2011 19:28:36 +0530 Subject: Revert "add a missing "on" and remove the "endprologue" text" This reverts commit 3c5340ec9cbf12d19e734289ba748186af492d60. Reason: endprologue should not have been removed. --- railties/guides/source/i18n.textile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 46f6942d02..81d2ba9a56 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -16,7 +16,9 @@ In the process of _localizing_ your application you'll probably want to do the f * Abstract strings in your application into keyed dictionaries -- e.g. flash messages, static text in your views, etc. * Store the resulting dictionaries somewhere -This guide will walk you through the I18n API and contains a tutorial on how to internationalize a Rails application from the start. +This guide will walk you through the I18n API and contains a tutorial how to internationalize a Rails application from the start. + +endprologue. NOTE: The Ruby I18n framework provides you with all necessary means for internationalization/localization of your Rails application. You may, however, use any of various plugins and extensions available, which add additional functionality or features. See the Rails "I18n Wiki":http://rails-i18n.org/wiki for more information. -- cgit v1.2.3