| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This feature adds a lot of complication to ActiveRecord for dubious
value. Let's talk about what it does currently:
class Customer < ActiveRecord::Base
composed_of :balance, :class_name => "Money", :mapping => %w(balance amount)
end
Instead, you can do something like this:
def balance
@balance ||= Money.new(value, currency)
end
def balance=(balance)
self[:value] = balance.value
self[:currency] = balance.currency
@balance = balance
end
Since that's fairly easy code to write, and doesn't need anything
extra from the framework, if you use composed_of today, you'll
have to add accessors/mutators like that.
Closes #1436
Closes #2084
Closes #3807
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There are two possible scenarios where the @mass_assignment_options
instance variable can become corrupted:
1. If the assign_attributes doesn't complete correctly, then
subsequent calls to a nested attribute assignment method will use
whatever options were passed to the previous assign_attributes call.
2. With nested assign_attributes calls, the inner call will overwrite
the current options. This will only affect nested attributes as the
attribute hash is sanitized before any methods are called.
To fix this we save the current options in a local variable and then
restore these options in an ensure block.
|
|
|
|
| |
Only constantize class_name once.
|
|\
| |
| | |
allow the :converter Proc form composed_of to return nil
|
| |
| |
| |
| |
| |
| |
| | |
This makes it possible to filter invalid input values before they are passed
into the value-object (like empty strings). This behaviour is only relevant
if the :allow_nil options is set to true. Otherwise you will get
the resulting NoMethodError.
|
| |
| |
| |
| | |
used out of the box.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Change CollectionProxy#method_missing to use scoped.public_send, to
avoid a problem described in issue #2508 when trying to use class
methods with names like "open", that clash with private kernel methods.
Also changed the dynamic matcher instantiator to send straight to
scoped, to avoid another roundtrip to method_missing.
|
| | |
|
| |
| |
| |
| | |
things
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| | |
(as described in #5667)
|
|\ \
| | |
| | | |
Fix deleting from a HABTM join table upon destroying an object of a model with optimistic locking enabled.
|
| | | |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Don't use this:
scope :red, where(color: 'red')
default_scope where(color: 'red')
Use this:
scope :red, -> { where(color: 'red') }
default_scope { where(color: 'red') }
The former has numerous issues. It is a common newbie gotcha to do
the following:
scope :recent, where(published_at: Time.now - 2.weeks)
Or a more subtle variant:
scope :recent, -> { where(published_at: Time.now - 2.weeks) }
scope :recent_red, recent.where(color: 'red')
Eager scopes are also very complex to implement within Active
Record, and there are still bugs. For example, the following does
not do what you expect:
scope :remove_conditions, except(:where)
where(...).remove_conditions # => still has conditions
|
| | | |
|
|/ /
| |
| |
| | |
:strict
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
If a model belongs_to two associations with the same class, then reset_counters
will reset the wrong counter cache.
Finding the right reflection should use the foreign_key instead, which should
be unique.
|
| |
| |
| |
| |
| |
| | |
See the CHANGELOG for details.
Fixes #950.
|
| |
| |
| |
| | |
This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
|
| | |
|
|\ \ |
|
| | |
| | |
| | |
| | |
| | |
| | | |
Test using fixtures with random names and model names, that is not following naming conventions but using set_fixture_class instead.
It is expected that the table name be defined in the model, but this is not explicitly tested here. This will need to be fixed.
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This is the 'top level' connection, inherited by any models that include
ActiveRecord::Model or inherit from ActiveRecord::Base.
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
strict mass assignment sanitizer, fixed build_record to not merge creation_attributes, removed failing nested attributes tests (that feature was broken anyway) #4051
|
| | | |
|
| | |
| | |
| | |
| | | |
object. Fixes a regression from 3.0.x
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | | |
method.
|
| | | |
|
| | | |
|
| | |
| | |
| | |
| | |
| | | |
This is to avoid confusing newbies, and to be consistent with the fact
that other options like :foreign_key already allow a symbol or a string.
|
| | | |
|
| | |
| | |
| | |
| | | |
stores [DHH]
|