| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
| |
While it's interesting to have the results array, it can make a console or a webpage freeze if there are a lot of them.
So this limits the number of records displayed in #inspect to 10 and tells how much were effectively found.
|
|
|
|
|
| |
See 07314e64fd62fb8e6165c8c539420160da9437e9.
Also fix some tabs in AR Changelog.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The reason for removing the previous implementation of `#inspect` was
that it hid from you that you were dealing with a `Relation` rather than
an `Array`.
But it is still useful to be able to see the records, particularly if you're
writing something like the following in tests:
assert_equal [foo], Post.where(:bar)
If the assertion fails, you want to see what records were actually
loaded.
So this implementation makes it clear that you've got a `Relation`, but
also shows your records.
|
| |
|
|
|
|
|
|
|
| |
Also fix some wrong formatting.
Related discussion:
https://github.com/rails/rails/commit/ab72040b74f742b6676b2d2a5dd029bfdca25a7a#commitcomment-1525256
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
`FinderMethods#exists?` finder method now returns *false* with the *false* argument
|
|
|
|
|
|
|
|
|
|
| |
This patch addresses the difficulty of retrieving datetime fields. By default, the database holds a higher precision than the time as a String.
This issue is discussed at length at the following links:
- [#3519](https://github.com/rails/rails/issues/3519)
- [#3520](https://github.com/rails/rails/issues/3520)
Also, kudos to @mattscilipoti
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improve the derivation of HABTM join table name to take account of nesting.
It now takes the table names of the two models, sorts them lexically and
then joins them, stripping any common prefix from the second table name.
Some examples:
Top level models
(Category <=> Product)
Old: categories_products
New: categories_products
Top level models with a global table_name_prefix
(Category <=> Product)
Old: site_categories_products
New: site_categories_products
Nested models in a module without a table_name_prefix method
(Admin::Category <=> Admin::Product)
Old: categories_products
New: categories_products
Nested models in a module with a table_name_prefix method
(Admin::Category <=> Admin::Product)
Old: categories_products
New: admin_categories_products
Nested models in a parent model
(Catalog::Category <=> Catalog::Product)
Old: categories_products
New: catalog_categories_products
Nested models in different parent models
(Catalog::Category <=> Content::Page)
Old: categories_pages
New: catalog_categories_content_pages
Also as part of this commit the validity checks for HABTM assocations have
been moved to ActiveRecord::Reflection One side effect of this is to move when
the exceptions are raised from the point of declaration to when the association
is built. This is consistant with other association validity checks.
|
| |
|
|
|
|
|
|
| |
This allows you to retrieve the list of attributes you've defined.
Usable for e.g. selects in the view, or interators based on the
attributes you wish to store in the serialized column.
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
| |
That change to update_attribute was considered
to be too subtle and was reverted in 30ea923
just before Rails 3 shipped. Later we introduced
update_column (Rails 3.1).
|
| |
|
| |
|
| |
|
|
|
|
| |
Missed that too, thanks again @splattael.
|
|
|
|
| |
Add Changelog entry. Closes #4003
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I found the next issue between CollectionAssociation `delete`
and `destroy`.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.destroy(1)
# => OK, returns the destroyed object
person.pets.destroy("2")
# => OK, returns the destroyed object
person.pets.delete(1)
# => ActiveRecord::AssociationTypeMismatch
person.pets.delete("2")
# => ActiveRecord::AssociationTypeMismatch
Adding support for deleting with a fixnum or string like
`destroy` method.
|
| |
|
| |
|
| |
|
|
|
|
| |
Record.from("(#{sub_query.to_sql})") -> Record.from(sub_query)
Record.from("(#{sub_query.to_sql}) a") -> Record.from(sub_query, :a)
|
| |
|
| |
|
| |
|
|
|
|
| |
used out of the box.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
The release date details have been taken from
http://weblog.rubyonrails.org/2012/3/30/ann-rails-3-2-3-has-been-released/
|
| |
|
|
|
|
|
| |
The main reason for this is that I want to separate the code that does
the mutating from the code that does the cloning.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
| |
|
| |
|