From 7ea0a50126a5b8f988fcf1c3fb0c57bdb52918c7 Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Sat, 8 Mar 2014 20:23:15 +0100 Subject: Updating select helper doc [ci skip] --- guides/source/form_helpers.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'guides') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 455dc7bebe..205e0f6b62 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -474,6 +474,16 @@ As with other helpers, if you were to use the `select` helper on a form builder <%= f.select(:city_id, ...) %> ``` +You can also pass a block to `select` helper: + +```erb +<%= f.select(:city_id) do %> + <% [['Lisbon', 1], ['Madrid', 2]].each do |c| -%> + <%= content_tag(:option, c.first, value: c.last) %> + <% end %> +<% end %> +``` + WARNING: If you are using `select` (or similar helpers such as `collection_select`, `select_tag`) to set a `belongs_to` association you must pass the name of the foreign key (in the example above `city_id`), not the name of association itself. If you specify `city` instead of `city_id` Active Record will raise an error along the lines of ` ActiveRecord::AssociationTypeMismatch: City(#17815740) expected, got String(#1138750) ` when you pass the `params` hash to `Person.new` or `update`. Another way of looking at this is that form helpers only edit attributes. You should also be aware of the potential security ramifications of allowing users to edit foreign keys directly. ### Option Tags from a Collection of Arbitrary Objects -- cgit v1.2.3 From 15a18c18e496c8fb46ee21d8a1af0c4012abc5f5 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Thu, 27 Mar 2014 16:37:47 +0530 Subject: Clarify environment_name for logs [ci skip] --- guides/source/debugging_rails_applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 226137c89a..99f685e535 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -123,7 +123,7 @@ config.logger = Logger.new(STDOUT) config.logger = Log4r::Logger.new("Application Log") ``` -TIP: By default, each log is created under `Rails.root/log/` and the log file name is `environment_name.log`. +TIP: By default, each log is created under `Rails.root/log/` and the log file name is `environment_name.log`. example `production.log`, `development.log` etc. ### Log Levels -- cgit v1.2.3 From f8872d658e7f2bee3a18be47c01754368f22ab73 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 29 Mar 2014 17:08:07 +0530 Subject: copy edit [ci skip] --- guides/source/debugging_rails_applications.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides') diff --git a/guides/source/debugging_rails_applications.md b/guides/source/debugging_rails_applications.md index 99f685e535..0e10d1b697 100644 --- a/guides/source/debugging_rails_applications.md +++ b/guides/source/debugging_rails_applications.md @@ -123,7 +123,7 @@ config.logger = Logger.new(STDOUT) config.logger = Log4r::Logger.new("Application Log") ``` -TIP: By default, each log is created under `Rails.root/log/` and the log file name is `environment_name.log`. example `production.log`, `development.log` etc. +TIP: By default, each log is created under `Rails.root/log/` and the log file is named after the environment in which the application is running. ### Log Levels -- cgit v1.2.3