From e22ad7ae1da0e2a78aaa33c33b272a230d9e8d28 Mon Sep 17 00:00:00 2001 From: Francesc Esplugas Date: Sun, 7 Nov 2010 22:08:59 +0100 Subject: Fixes ActionMailer example error --- railties/guides/source/action_mailer_basics.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile index 2259061c30..41738827b2 100644 --- a/railties/guides/source/action_mailer_basics.textile +++ b/railties/guides/source/action_mailer_basics.textile @@ -492,7 +492,7 @@ class UserMailerTest < ActionMailer::TestCase user = users(:some_user_in_your_fixtures) # Send the email, then test that it got queued - email = UserMailer.deliver_welcome_email(user) + email = UserMailer.welcome_email(user).deliver assert !ActionMailer::Base.deliveries.empty? # Test the body of the sent email contains what we expect it to -- cgit v1.2.3 From 4d5807bcd5bd57e96ea7f9981dae9913289a078d Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Mon, 8 Nov 2010 03:47:45 -0500 Subject: corrected to Rails 3 syntax for declaring resources --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 80e0421b48..341d4b1c27 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -284,7 +284,7 @@ h4. Relying on Record Identification The Article model is directly available to users of the application, so -- following the best practices for developing with Rails -- you should declare it *a resource*: -map.resources :articles +resources :articles TIP: Declaring a resource has a number of side-affects. See "Rails Routing From the Outside In":routing.html#resource-routing-the-rails-default for more information on setting up and using resources. -- cgit v1.2.3 From e135f13f50319fdce660627972089d49363029ca Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Mon, 8 Nov 2010 03:58:19 -0500 Subject: added missing space and minor rewording --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 341d4b1c27..b38b134b61 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -67,7 +67,7 @@ A basic search form <% end %> -TIP: +search_path+ can be a named route specified in "routes.rb" as:
match "search" => "search"This declares for path "/search" to call action "search" from controller "search". +TIP: +search_path+ can be a named route specified in "routes.rb" as:
match "search" => "search" This declares path "/search" will be handled by action "search" belonging to controller "search". The above view code will result in the following markup: -- cgit v1.2.3 From 149f795d168897d36ce07a243b3e83ba724752ab Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Mon, 8 Nov 2010 04:04:18 -0500 Subject: removed etc. not require --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index b38b134b61..16aad5aa9e 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -107,7 +107,7 @@ WARNING: Do not delimit the second hash without doing so with the first hash, ot h4. Helpers for Generating Form Elements -Rails provides a series of helpers for generating form elements such as checkboxes, text fields, radio buttons, and so on. These basic helpers, with names ending in _tag such as +text_field_tag+, +check_box_tag+, etc., generate just a single +<input>+ element. The first parameter to these is always the name of the input. In the controller this name will be the key in the +params+ hash used to get the value entered by the user. For example, if the form contains +Rails provides a series of helpers for generating form elements such as checkboxes, text fields, radio buttons, and so on. These basic helpers, with names ending in _tag such as +text_field_tag+, +check_box_tag+, generate just a single +<input>+ element. The first parameter to these is always the name of the input. In the controller this name will be the key in the +params+ hash used to get the value entered by the user. For example, if the form contains <%= text_field_tag(:query) %> -- cgit v1.2.3 From 78e085b12cbd10c249df03a42014ad6fd257bc25 Mon Sep 17 00:00:00 2001 From: dmathieu <42@dmathieu.com> Date: Mon, 8 Nov 2010 10:14:15 +0100 Subject: Use Rails.logger, not ActiveRecord::Base.logger Because everybody is not using ActiveRecord. And the logger is not specific to it. --- railties/guides/source/debugging_rails_applications.textile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/debugging_rails_applications.textile b/railties/guides/source/debugging_rails_applications.textile index 6eec18b8b9..adf427147b 100644 --- a/railties/guides/source/debugging_rails_applications.textile +++ b/railties/guides/source/debugging_rails_applications.textile @@ -127,8 +127,8 @@ Rails makes use of Ruby's standard +logger+ to write log information. You can al You can specify an alternative logger in your +environment.rb+ or any environment file: -ActiveRecord::Base.logger = Logger.new(STDOUT) -ActiveRecord::Base.logger = Log4r::Logger.new("Application Log") +Rails.logger = Logger.new(STDOUT) +Rails.logger = Log4r::Logger.new("Application Log") Or in the +Initializer+ section, add _any_ of the following @@ -142,13 +142,13 @@ TIP: By default, each log is created under +Rails.root/log/+ and the log file na h4. Log Levels -When something is logged it's printed into the corresponding log if the log level of the message is equal or higher than the configured log level. If you want to know the current log level you can call the +ActiveRecord::Base.logger.level+ method. +When something is logged it's printed into the corresponding log if the log level of the message is equal or higher than the configured log level. If you want to know the current log level you can call the +Rails.logger.level+ method. The available log levels are: +:debug+, +:info+, +:warn+, +:error+, and +:fatal+, corresponding to the log level numbers from 0 up to 4 respectively. To change the default log level, use config.log_level = Logger::WARN # In any environment initializer, or -ActiveRecord::Base.logger.level = 0 # at any time +Rails.logger.level = 0 # at any time This is useful when you want to log under development or staging, but you don't want to flood your production log with unnecessary information. -- cgit v1.2.3 From 4b7ac55780bc5bb4c65bb9fc45b7607b67dc64d6 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Mon, 8 Nov 2010 04:17:56 -0500 Subject: removed indentation, for code style consistency and readibility --- railties/guides/source/form_helpers.textile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 16aad5aa9e..3b7cd2a7ab 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -127,18 +127,18 @@ Checkboxes are form controls that give the user a set of options they can enable <%= check_box_tag(:pet_dog) %> - <%= label_tag(:pet_dog, "I own a dog") %> +<%= label_tag(:pet_dog, "I own a dog") %> <%= check_box_tag(:pet_cat) %> - <%= label_tag(:pet_cat, "I own a cat") %> +<%= label_tag(:pet_cat, "I own a cat") %> output: - + - + The second parameter to +check_box_tag+ is the value of the input. This is the value that will be submitted by the browser if the checkbox is ticked (i.e. the value that will be present in the +params+ hash). With the above form you would check the value of +params[:pet_dog]+ and +params[:pet_cat]+ to see which pets the user owns. @@ -149,18 +149,18 @@ Radio buttons, while similar to checkboxes, are controls that specify a set of o <%= radio_button_tag(:age, "child") %> - <%= label_tag(:age_child, "I am younger than 21") %> +<%= label_tag(:age_child, "I am younger than 21") %> <%= radio_button_tag(:age, "adult") %> - <%= label_tag(:age_adult, "I'm over 21") %> +<%= label_tag(:age_adult, "I'm over 21") %> output: - + - + As with +check_box_tag+ the second parameter to +radio_button_tag+ is the value of the input. Because these two radio buttons share the same name (age) the user will only be able to select one and +params[:age]+ will contain either "child" or "adult". -- cgit v1.2.3 From 4e074c7cc64a5f6d9f93f7782a0cdd1d50652403 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Tue, 9 Nov 2010 04:34:32 -0500 Subject: added missing word to clear up meaning in my previous commit --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 3b7cd2a7ab..52c8a752f6 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -67,7 +67,7 @@ A basic search form <% end %> -TIP: +search_path+ can be a named route specified in "routes.rb" as:
match "search" => "search" This declares path "/search" will be handled by action "search" belonging to controller "search". +TIP: +search_path+ can be a named route specified in "routes.rb" as:
match "search" => "search" This declares that path "/search" will be handled by action "search" belonging to controller "search". The above view code will result in the following markup: -- cgit v1.2.3 From 5cdb46d9fb1d9afc72d9a2033d18897b6958154f Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Tue, 9 Nov 2010 05:05:56 -0500 Subject: this reads better, i don't know what the other 'so on' are, doesn't help reader imho --- railties/guides/source/form_helpers.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 52c8a752f6..514be33a40 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -107,7 +107,7 @@ WARNING: Do not delimit the second hash without doing so with the first hash, ot h4. Helpers for Generating Form Elements -Rails provides a series of helpers for generating form elements such as checkboxes, text fields, radio buttons, and so on. These basic helpers, with names ending in _tag such as +text_field_tag+, +check_box_tag+, generate just a single +<input>+ element. The first parameter to these is always the name of the input. In the controller this name will be the key in the +params+ hash used to get the value entered by the user. For example, if the form contains +Rails provides a series of helpers for generating form elements such as checkboxes, text fields and radio buttons. These basic helpers, with names ending in _tag such as +text_field_tag+ and +check_box_tag+ generate just a single +<input>+ element. The first parameter to these is always the name of the input. In the controller this name will be the key in the +params+ hash used to get the value entered by the user. For example, if the form contains <%= text_field_tag(:query) %> -- cgit v1.2.3 From e7723baa0b904787bde363f55912f7e71aa4517d Mon Sep 17 00:00:00 2001 From: Frederick Ros Date: Thu, 11 Nov 2010 23:02:05 +0100 Subject: Fixed the name of the 'generator option' --- railties/guides/source/plugins.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile index 7c2725e652..d32e7de564 100644 --- a/railties/guides/source/plugins.textile +++ b/railties/guides/source/plugins.textile @@ -802,7 +802,7 @@ You can also see if your routes work by running +rake routes+ from your app dire h3. Generators -Many plugins ship with generators. When you created the plugin above, you specified the +--with-generator+ option, so you already have the generator stubs in 'vendor/plugins/yaffle/generators/yaffle'. +Many plugins ship with generators. When you created the plugin above, you specified the +--generator+ option, so you already have the generator stubs in 'vendor/plugins/yaffle/generators/yaffle'. Building generators is a complex topic unto itself and this section will cover one small aspect of generators: generating a simple text file. -- cgit v1.2.3 From d44cd370bfd044d460359ec8c2bb5ce36451d341 Mon Sep 17 00:00:00 2001 From: Paco Guzman Date: Sat, 13 Nov 2010 12:17:21 +0100 Subject: colorize_logging is a Rails General Configuration option not a specific option of ActiveRecord --- railties/guides/source/configuring.textile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index bb38c64307..28fff5c11e 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -32,7 +32,7 @@ config.filter_parameters << :password This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same +config+ object: -config.active_record.colorize_logging = false +config.active_record.timestamped_migrations = false Rails will use that particular setting to configure Active Record. @@ -45,6 +45,8 @@ h4. Rails General Configuration * +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class. +* +config.colorize_logging+ (true by default) specifies whether or not to use ANSI color codes when logging information. + * +config.controller_paths+ accepts an array of paths that will be searched for controllers. Defaults to +app/controllers+. * +config.database_configuration_file+ overrides the default path for the database configuration file. Default to +config/database.yml+. @@ -105,8 +107,6 @@ h4. Configuring Active Record * +config.active_record.pluralize_table_names+ specifies whether Rails will look for singular or plural table names in the database. If set to +true+ (the default), then the Customer class will use the +customers+ table. If set to +false+, then the Customers class will use the +customer+ table. -* +config.active_record.colorize_logging+ (true by default) specifies whether or not to use ANSI color codes when logging information from ActiveRecord. - * +config.active_record.default_timezone+ determines whether to use +Time.local+ (if set to +:local+) or +Time.utc+ (if set to +:utc+) when pulling dates and times from the database. The default is +:local+. * +config.active_record.schema_format+ controls the format for dumping the database schema to a file. The options are +:ruby+ (the default) for a database-independent version that depends on migrations, or +:sql+ for a set of (potentially database-dependent) SQL statements. -- cgit v1.2.3 From 7e1f6688e92c18f9973ad65db7b95de495b98947 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sat, 13 Nov 2010 20:24:04 -0500 Subject: the partial option is not required for simple partial rendering --- railties/guides/source/layouts_and_rendering.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile index c65ea5c797..4e26d152bf 100644 --- a/railties/guides/source/layouts_and_rendering.textile +++ b/railties/guides/source/layouts_and_rendering.textile @@ -970,7 +970,7 @@ Partial templates - usually just called "partials" - are another device for brea h5. Naming Partials -To render a partial as part of a view, you use the +render+ method within the view, and include the +:partial+ option: +To render a partial as part of a view, you use the +render+ method within the view: <%= render "menu" %> -- cgit v1.2.3 From 23f71c431dae9ec389a861700ea84c7b0cbf913c Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 05:12:01 -0500 Subject: corrected sample code to clear @_current_user class variable also --- railties/guides/source/action_controller_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index c02e9f1912..3774c7fcf5 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -239,7 +239,7 @@ class LoginsController < ApplicationController # "Delete" a login, aka "log the user out" def destroy # Remove the user id from the session - session[:current_user_id] = nil + @_current_user = session[:current_user_id] = nil redirect_to root_url end end -- cgit v1.2.3 From f69784289b6efd0eabb674d6467b2cd0c0a4af07 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 05:20:10 -0500 Subject: added note with example for using flash in redirection --- railties/guides/source/action_controller_overview.textile | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index 3774c7fcf5..cabc0c8a7f 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -261,6 +261,13 @@ class LoginsController < ApplicationController end +Note it is also possible to assign a flash message as part of the redirection. + + + redirect_to root_url, :notice => "You have successfully logged out" + + + The +destroy+ action redirects to the application's +root_url+, where the message will be displayed. Note that it's entirely up to the next action to decide what, if anything, it will do with what the previous action put in the flash. It's conventional to display eventual errors or notices from the flash in the application's layout: -- cgit v1.2.3 From abf225423cbe11fcb0460a40bd49263694eaef06 Mon Sep 17 00:00:00 2001 From: Rajinder Yadav Date: Sun, 14 Nov 2010 06:02:16 -0500 Subject: removed unnecessary indentation --- railties/guides/source/action_controller_overview.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile index cabc0c8a7f..b39075f101 100644 --- a/railties/guides/source/action_controller_overview.textile +++ b/railties/guides/source/action_controller_overview.textile @@ -264,7 +264,7 @@ end Note it is also possible to assign a flash message as part of the redirection. - redirect_to root_url, :notice => "You have successfully logged out" +redirect_to root_url, :notice => "You have successfully logged out" -- cgit v1.2.3 From 330d65d31222148019855d6914e35c8cd9f90cd5 Mon Sep 17 00:00:00 2001 From: Aditya Sanghi Date: Sun, 14 Nov 2010 18:27:08 +0530 Subject: deliver_* is no more --- railties/guides/source/action_mailer_basics.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/action_mailer_basics.textile b/railties/guides/source/action_mailer_basics.textile index 41738827b2..8d2ce44e93 100644 --- a/railties/guides/source/action_mailer_basics.textile +++ b/railties/guides/source/action_mailer_basics.textile @@ -446,7 +446,7 @@ The following configuration options are best made in one of the environment file |sendmail_settings|Allows you to override options for the :sendmail delivery method.
  • :location - The location of the sendmail executable. Defaults to /usr/sbin/sendmail.
  • :arguments - The command line arguments to be passed to sendmail. Defaults to -i -t.
| |raise_delivery_errors|Whether or not errors should be raised if the email fails to be delivered.| |delivery_method|Defines a delivery method. Possible values are :smtp (default), :sendmail, :file and :test.| -|perform_deliveries|Determines whether deliver_* methods are actually carried out. By default they are, but this can be turned off to help functional testing.| +|perform_deliveries|Determines whether deliveries are actually carried out when the +deliver+ method is invoked on the Mail message. By default they are, but this can be turned off to help functional testing.| |deliveries|Keeps an array of all the emails sent out through the Action Mailer with delivery_method :test. Most useful for unit and functional testing.| h4. Example Action Mailer Configuration -- cgit v1.2.3 From 324569bb113ab6525d3eb1d5e35fa6bc911917eb Mon Sep 17 00:00:00 2001 From: Jaime Iniesta Date: Mon, 15 Nov 2010 00:07:25 +0100 Subject: Getting Started guide: remove calls to f.error_messages as it has been removed from Rails --- railties/guides/source/getting_started.textile | 8 -------- 1 file changed, 8 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index e592417dcb..f3420e37d1 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -919,8 +919,6 @@ So first, we'll wire up the Post show template (+/app/views/posts/show.html.erb+

Add a comment:

<%= form_for([@post, @post.comments.build]) do |f| %> - <%= f.error_messages %> -
<%= f.label :commenter %>
<%= f.text_field :commenter %> @@ -989,8 +987,6 @@ Once we have made the new comment, we send the user back to the original post us

Add a comment:

<%= form_for([@post, @post.comments.build]) do |f| %> - <%= f.error_messages %> -
<%= f.label :commenter %>
<%= f.text_field :commenter %> @@ -1057,8 +1053,6 @@ Then in the +app/views/posts/show.html.erb+ you can change it to look like the f

Add a comment:

<%= form_for([@post, @post.comments.build]) do |f| %> - <%= f.error_messages %> -
<%= f.label :commenter %>
<%= f.text_field :commenter %> @@ -1086,8 +1080,6 @@ Lets also move that new comment section out to it's own partial, again, you crea <%= form_for([@post, @post.comments.build]) do |f| %> - <%= f.error_messages %> -
<%= f.label :commenter %>
<%= f.text_field :commenter %> -- cgit v1.2.3 From c2c2b8b96220b11eb3512b1eaaf7985c84f03d67 Mon Sep 17 00:00:00 2001 From: James Miller Date: Mon, 15 Nov 2010 09:26:57 -0700 Subject: Add HTTP Verb Constraints (:via) to routing guide --- railties/guides/source/routing.textile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile index f48ae9c7f7..cc0c3316c8 100644 --- a/railties/guides/source/routing.textile +++ b/railties/guides/source/routing.textile @@ -436,6 +436,26 @@ match 'exit' => 'sessions#destroy', :as => :logout This will create +logout_path+ and +logout_url+ as named helpers in your application. Calling +logout_path+ will return +/exit+ +h4. HTTP Verb Constraints + +You can use the +:via+ option to constrain the request to one or more HTTP methods: + + +match 'photos/show' => 'photos#show', :via => :get + + +There is a shorthand version of this as well: + + +get 'photos/show' + + +You can also permit more than one verb to a single route: + + +match 'photos/show' => 'photos#show', :via => [:get, :post] + + h4. Segment Constraints You can use the +:constraints+ option to enforce a format for a dynamic segment: -- cgit v1.2.3