| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Allows you to specify the model association key in a belongs_to
relationship instead of the foreign key.
The following queries are now equivalent:
Post.where(:author_id => Author.first)
Post.where(:author => Author.first)
PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure)
PriceEstimate.where(:estimate_of => treasure)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When calling a query method on an attribute that was not selected by
an ActiveRecord query, an ActiveModel::MissingAttributeError is not
raised. Instead, a nil value is returned, which will return false once
cast to boolean.
This is undesirable, as we should not give the impression that we know
the attribute's boolean value when we haven't loaded the attribute's
(possibly) non-boolean value from the database.
This issue is present on versions going back as far as 2.3, at least.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
Merged in f41dba27a411fe3e2ddeb8d9ab6856dbb23acd02
[ci skip]
|
|
|
|
|
|
|
|
| |
Since 810a50dacf9ddddc1d59c1cb350e8ce785c8bf85, the new policy is to
keep old changelogs in their own branches, to avoid manual syncing
across different branches.
Please check that commit for more reasoning about the new policy.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
This implements the support to encode/decode JSON
data to/from database and creating columns of type
JSON using a native type [1] supported by PostgreSQL
from version 9.2.
[1] http://www.postgresql.org/docs/9.2/static/datatype-json.html
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Changes in old branches needed to be manually synched in CHANGELOGs of newer ones.
This has proven to be brittle, sometimes one just forgets this manual step.
With this commit we switch to CHANGELOGs per branch. When a new major version is
cut from master, the CHANGELOGs in master start being blank.
A link to the CHANGELOG of the previous branch allows anyone interested to
follow the history.
|
|
|
|
| |
We reverted the removal because the new deprecation policy
|
| |
|
|
|
|
|
| |
This functionality will be available from gem
`active_record-session_store` instead.
|
|
|
|
|
|
| |
associations with the same foreign key.
This closes #5200.
|
| |
|
| |
|
| |
|
|\
| |
| | |
Fix occasional microsecond conversion inaccuracy
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
ActiveRecord::ConnectionAdapters::Column#microseconds did an unnecessary
conversion to from Rational to float when calculating the integer number
of microseconds. Some terminating decimal numbers in base10 are
repeating decimal numbers in base2 (the format of float), and
occasionally this causes a rounding error.
Patch & explanation originally from Logan Bowers.
|
|/
|
|
| |
For consistency with the other AR extension plugins we are creating.
|
| |
|
| |
|
|\
| |
| |
| | |
Change Relation#update_all with blank argument to raise an ArgumentError
instead of trying an update with empty fields.
|
| | |
|
| |
| |
| |
| | |
This fixes issue #3217.
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
It's not really a good idea to have this as a global config option. We
should allow people to specify the behaviour per association.
There will now be two new values:
* :dependent => :restrict_with_exception implements the current
behaviour of :restrict. :restrict itself is deprecated in favour of
:restrict_with_exception.
* :dependent => :restrict_with_error implements the new behaviour - it
adds an error to the owner if there are dependent records present
See #4727 for the original discussion of this.
|
|\ \
| | |
| | |
| | |
| | | |
Make sure :environment task is executed before db:schema:load or
db:structure:load
|
| |/ |
|
| |
| |
| |
| |
| | |
On reflection, it seems like a bit of a weird method to have on
ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This was requested by DHH to allow creating of one's own custom
association macros.
For example:
module Commentable
def has_many_comments(extra)
has_many :comments, -> { where(:foo).merge(extra) }
end
end
class Post < ActiveRecord::Base
extend Commentable
has_many_comments -> { where(:bar) }
end
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This can be used to get a Relation from an association.
Previously we had a #scoped method, but we're deprecating that for
AR::Base, so it doesn't make sense to have it here.
This was requested by DHH, to facilitate code like this:
Project.scope.order('created_at DESC').page(current_page).tagged_with(@tag).limit(5).scoping do
@topics = @project.topics.scope
@todolists = @project.todolists.scope
@attachments = @project.attachments.scope
@documents = @project.documents.scope
end
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This method explicitly loads the records and then returns `self`.
Rather than deciding between "do I want an array or a relation?",
most people are actually asking themselves "do I want to eager load
or lazy load?" Therefore, this method provides a way to explicitly
eager-load without having to switch from a `Relation` to an array.
Example:
@posts = Post.where(published: true).load
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370.
Conflicts:
activerecord/CHANGELOG.md
It will be deprecated only in 4.0, and removed properly in 4.1.
|
| |
| |
| |
| | |
e35c67ae0f920011a2440210041e96659a8de985
|
| |
| |
| |
| |
| |
| |
| | |
User.order("name asc").order("created_at desc")
# SELECT * FROM users ORDER BY created_at desc, name asc
This also affects order defined in `default_scope` or any kind of associations.
|
| |
| |
| |
| |
| |
| | |
update_column was suggested as replacement of update_attribute at the
last release of 3-2-stable, so deprecating it now will confuse the
users.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592.
Reason: we need to discuss a better path from this removal.
Conflicts:
activerecord/lib/active_record/reflection.rb
activerecord/test/cases/base_test.rb
activerecord/test/models/developer.rb
|
|\ \
| | |
| | | |
Validates_presence_of associated object marked for destruction
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This allows us to mark the parent object as invalid if all associated objects
in a presence validated association are marked for destruction.
See: https://github.com/rails/rails/issues/6812
|
| | | |
|