aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/car.rb
Commit message (Collapse)AuthorAgeFilesLines
* remove deprecated scope stuffJon Leighton2012-04-261-1/+0
|
* Deprecate eager-evaluated scopes.Jon Leighton2012-03-211-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Test polymorphic record with optimistic locking and counter cache should be ↵Dmitry Polushkin2011-09-091-1/+1
| | | | destoyed without catching the ActiveRecord::StaleObjectError.
* Ensure we are not comparing a string with a symbol in ↵Jon Leighton2011-09-061-1/+1
| | | | HasManyAssociation#inverse_updates_counter_cache?. Fixes #2755, where a counter cache could be decremented twice as far as it was supposed to be.
* Don't use mass-assignment protection when setting foreign keys or ↵Jon Leighton2011-05-121-0/+3
| | | | association conditions on singular associations. Fixes #481 (again).
* Add test to specify that attributes from an association's conditions should ↵Jon Leighton2011-05-101-0/+2
| | | | be assigned without mass-assignment protection when a record is built on the association.
* Un-deprecate using 'default_scope' as a macro, but if you are calling the ↵Jon Leighton2011-04-181-6/+2
| | | | macro multiple times that will give deprecation warnings, and in 3.2 we will simply overwrite the default scope when you call the macro multiple times.
* Deprecated support for passing hashes and relations to default_scope, in ↵Jon Leighton2011-04-121-2/+7
| | | | favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
* expanding the test to include both type of order declarationNeeraj Singh2010-09-181-2/+9
| | | | | | | | | while declaring default_scope Also added test for unscoped using block style with four different combinations Signed-off-by: José Valim <jose.valim@gmail.com>
* order should always be concatenated.Neeraj Singh2010-09-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | order that is declared first has highest priority in all cases. Here are some examples. Car.order('name desc').find(:first, :order => 'id').name Car.named_scope_with_order.named_scope_with_another_order Car.order('id DESC').scoping do Car.find(:first, :order => 'id asc') end No special treatment to with_scope or scoping. Also note that if default_scope declares an order then the order declared in default_scope has the highest priority unless with_exclusive_scope is used. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* While creating a new record using has_many create method default scope of ↵Neeraj Singh2010-08-191-0/+1
| | | | | | | | | | | child should be respected. author.posts.create should take into account default_scope defined on post. [#3939: state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Ensure we can nest include calls [#5285 state:resolved]Neeraj Singh2010-08-121-0/+5
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* reset_counter should work with non-traditional belongs_to and polymorphic ↵Neeraj Singh2010-07-081-0/+4
belongs_to [#4984 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>