aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionview/lib/action_view/helpers/tags/search_field.rb20
-rw-r--r--actionview/lib/action_view/helpers/tags/text_field.rb1
-rw-r--r--actionview/test/template/form_helper_test.rb5
-rw-r--r--guides/source/active_record_migrations.md2
-rw-r--r--guides/source/testing.md2
5 files changed, 19 insertions, 11 deletions
diff --git a/actionview/lib/action_view/helpers/tags/search_field.rb b/actionview/lib/action_view/helpers/tags/search_field.rb
index c09e2f1be7..4597cec6fa 100644
--- a/actionview/lib/action_view/helpers/tags/search_field.rb
+++ b/actionview/lib/action_view/helpers/tags/search_field.rb
@@ -3,20 +3,18 @@ module ActionView
module Tags # :nodoc:
class SearchField < TextField # :nodoc:
def render
- options = @options.stringify_keys
-
- if options["autosave"]
- if options["autosave"] == true
- options["autosave"] = request.host.split(".").reverse.join(".")
+ super do |options|
+ if options["autosave"]
+ if options["autosave"] == true
+ options["autosave"] = request.host.split(".").reverse.join(".")
+ end
+ options["results"] ||= 10
end
- options["results"] ||= 10
- end
- if options["onsearch"]
- options["incremental"] = true unless options.has_key?("incremental")
+ if options["onsearch"]
+ options["incremental"] = true unless options.has_key?("incremental")
+ end
end
-
- super
end
end
end
diff --git a/actionview/lib/action_view/helpers/tags/text_field.rb b/actionview/lib/action_view/helpers/tags/text_field.rb
index 5c576a20ca..49fc81ec8c 100644
--- a/actionview/lib/action_view/helpers/tags/text_field.rb
+++ b/actionview/lib/action_view/helpers/tags/text_field.rb
@@ -11,6 +11,7 @@ module ActionView
options["size"] = options["maxlength"] unless options.key?("size")
options["type"] ||= field_type
options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
+ yield options if block_given?
add_default_name_and_id(options)
tag("input", options)
end
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index a131752b2a..1459b9f02a 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -928,6 +928,11 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal(expected, search_field("contact", "notes_query"))
end
+ def test_search_field_with_onsearch_value
+ expected = %{<input onsearch="true" type="search" name="contact[notes_query]" id="contact_notes_query" incremental="true" />}
+ assert_dom_equal(expected, search_field("contact", "notes_query", onsearch: true))
+ end
+
def test_telephone_field
expected = %{<input id="user_cell" name="user[cell]" type="tel" />}
assert_dom_equal(expected, telephone_field("user", "cell"))
diff --git a/guides/source/active_record_migrations.md b/guides/source/active_record_migrations.md
index c8a31fe7b8..1a41fc8b4c 100644
--- a/guides/source/active_record_migrations.md
+++ b/guides/source/active_record_migrations.md
@@ -452,6 +452,8 @@ number of digits after the decimal point.
are using a dynamic value (such as a date), the default will only be calculated
the first time (i.e. on the date the migration is applied).
* `index` Adds an index for the column.
+* `required` Adds `required: true` for `belongs_to` associations and
+`null: false` to the column in the migration.
Some adapters may support additional options; see the adapter specific API docs
for further information.
diff --git a/guides/source/testing.md b/guides/source/testing.md
index d54f431d54..40abac0507 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -122,6 +122,8 @@ Rails by default automatically loads all fixtures from the `test/fixtures` folde
* Load the fixture data into the table
* Dump the fixture data into a variable in case you want to access it directly
+TIP: In order to remove existing data from the database, Rails tries to disable referential integrity triggers (like foreign keys and check constraints). If you are getting annoying permission errors on running tests, make sure the database user has privilege to disable these triggers in testing environment. (In PostgreSQL, just superusers can disable all triggers. Read more about PostgreSQL permissions [here](http://blog.endpoint.com/2012/10/postgres-system-triggers-error.html))
+
#### Fixtures are Active Record objects
Fixtures are instances of Active Record. As mentioned in point #3 above, you can access the object directly because it is automatically setup as a local variable of the test case. For example: