Notes posted by amasses

RSS feed
November 6, 2011 - (>= v3.1.0)
3 thanks

Removed in 3.1.x

This method (and #auto_link_urls) has been removed in Rails 3.1 - other options are out there, such as Rinku, however there is a gem you can use for migration purposes etc, which is rails_autolink: http://rubygems.org/gems/rails_autolink

August 30, 2011 - (>= v3.0.0)
1 thank

Does not work for has_one associations

If you are using this to validate that a has_one association has been made with another object this will not work, as the test used in the AssociatedValidator #validates_each method tests for nil and then ignores this object.

To test for association with a has_one association you can use the following code:

validate do
  [:teacher, :book].each do |attr|
    errors.add(attr, "is required") if self.send(attr).nil?
August 9, 2011
1 thank

HTML5 support

To support multiple file selection simply pass :multiple => true in the options hash:

file_field_tag 'file', :accept => 'image/jpeg', :multiple => true
May 3, 2010 - (<= v1_8_7_72)
1 thank

Changes self

This method changes the object/array the method is called on. For example:

a = ["a", "b", "c"]
b = ["x", "y", "z"]

a.concat(b)  #=> [a", "b", "c", "z", "y", "z"]
a #=> [a", "b", "c", "z", "y", "z"]

In this example the object A is modified, the method modifies the object, then returns the new object.