We’ve released Ruby on Rails version 2.3.3. This release fixes a lot of bugs and introduces a handful of new features.
touch
is a convenient method to update a record’s timestamp and nothing else. This is extracted from apps whose models “touch” others when they change, such as a comment updating the parent.replies_changed_at timestamp after save and destroy. Timestamping an entire has_many association makes it easy to build a key for fragment caching that covers changes to the parent object and any of its children. This pattern is wrapped up as belongs_to :parent, :touch => :replies_changed_at
. When the child changes, parent.replies_changed_at
is touched. :touch => true
is defaults to :touch => :updated_at
.:primary_key
option for belongs_to
for broader support of legacy schemas and those using a separate UUID primary key: belongs_to :employee, :primary_key => 'SSN', :foreign_key => 'EMPID'
changesetActiveSupport::JSON.backend = 'JSONGem'
.to_json
with varying compatibility, safely overriding it is difficult. Most custom to_json
looks like
def to_json(*encoder_specific_args)
{ :some => "json representation" }.to_json(*encoder_specific_args)
end
so we DRYed the user-facing API down to a more natural
def as_json(options = {})
{ :some => "json representation" }
end
without the ugly internal state exposed by overloading to_json
as both public-facing and internal builder API. Rails 3 splits the API explicitly, so prepare now by switching from to_json
to as_json
.