Amparo Luna + Guillermo Iguaran
1f3a1fedf9
Rename update_attributes method to update, keep update_attributes as an alias
2013-01-03 11:51:21 -05:00
Carlos Antonio da Silva
7e10f38880
Initialize accessors to remove some warnings in Ruby 2.0
2012-11-19 12:52:19 -02:00
Jon Leighton
0a12a5f816
Deprecate eager-evaluated scopes.
...
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
2012-03-21 22:18:18 +00:00
Jon Leighton
6f84c73dc4
Un-deprecate using 'default_scope' as a macro, but if you are calling the 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.
2011-04-18 23:15:38 +01:00
Jon Leighton
5740d4ec0c
Deprecated support for passing hashes and relations to default_scope, in favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
2011-04-12 19:46:04 -07:00
Jon Leighton
735844db71
Merge branch 'master' into nested_has_many_through
...
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/association_preload.rb
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations/class_methods/join_dependency.rb
activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
activerecord/lib/active_record/associations/has_many_association.rb
activerecord/lib/active_record/associations/has_many_through_association.rb
activerecord/lib/active_record/associations/has_one_association.rb
activerecord/lib/active_record/associations/has_one_through_association.rb
activerecord/lib/active_record/associations/through_association_scope.rb
activerecord/lib/active_record/reflection.rb
activerecord/test/cases/associations/has_many_through_associations_test.rb
activerecord/test/cases/associations/has_one_through_associations_test.rb
activerecord/test/cases/reflection_test.rb
activerecord/test/cases/relations_test.rb
activerecord/test/fixtures/memberships.yml
activerecord/test/models/categorization.rb
activerecord/test/models/category.rb
activerecord/test/models/member.rb
activerecord/test/models/reference.rb
activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Jon Leighton
05bcb8cecc
Support the :dependent option on has_many :through associations. For historical and practical reasons, :delete_all is the default deletion strategy employed by association.delete(*records), despite the fact that the default strategy is :nullify for regular has_many. Also, this only works at all if the source reflection is a belongs_to. For other situations, you should directly modify the through association.
2011-02-07 23:35:05 +00:00
Jon Leighton
9a1a32ac2b
Fix naughty trailing whitespace
2010-10-31 11:21:28 +00:00
Jon Leighton
ab5a933502
Add support for nested through associations in JoinAssociation. Hence Foo.joins(:bar) will work for through associations. There is some duplicated code now, which will be refactored.
2010-10-09 22:00:33 +01:00
Subba Rao Pasupuleti
d77c3b669c
eagerly loaded association records should respect default_scope [ #2931 state:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-07-21 15:01:40 +02:00
Frederick Cheung
44d2142352
Ensure table names are quoted by the association preloading code.
...
[#45 state:resolved]
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2008-04-26 12:14:50 +12:00