Andrew White
45509ee6b7
Pass mass-assignment options to nested models - closes #1673 .
2011-06-13 13:07:44 +01:00
Jon Leighton
bdd549a1c0
Refactor tests to be less brittle
2011-06-12 18:31:26 +01:00
Erik Fonselius
c22364b60d
Failing test for aggregating on default_scope with select
2011-05-31 21:12:40 +01:00
Farley Knight
842043e352
Tests for issue #1360
2011-05-31 20:32:47 +01:00
Jon Leighton
b519b0cac9
Fix infinite recursion where a lazy default scope references a scope. Fixes #1264 .
2011-05-25 00:18:08 +01:00
Andrew White
8a4263c957
Ignore :includes on through associations
2011-05-25 00:17:53 +01:00
Andrew White
0daf574648
Failing tests for #1233 .
2011-05-25 00:17:00 +01:00
Guillermo Iguaran
23e94a67f8
Refactoring test_has_many_with_pluralize_table_names_false test
2011-05-20 01:53:13 -05:00
Andrew White
42f1ad6865
Pass the attribute and option hashes to build_association
...
The build_association method was added as an API for plugins
to hook into in 1398db0 . This commit restores this API and the
ability to override class.new to return a subclass based on
a virtual attribute in the attributes hash.
2011-05-17 20:43:30 +01:00
Jon Leighton
2033ff825b
Merge pull request #560 from guilleiguaran/fix_pluralize_table_names_false
...
Fixing has_many when ActiveRecord::Base.pluralize_table_names is false
2011-05-16 15:40:12 -07:00
Guillermo Iguaran
ecbde46e57
Fixing has_many association when ActiveRecord::Base.pluralize_table_names is false. fixes #557
2011-05-15 03:53:10 -05:00
Jon Leighton
60b23ea1da
CollectionAssociation#merge_target_lists should write to the underlying attributes when copying, rather than using the assignment method
2011-05-14 19:49:22 +01:00
Jon Leighton
6e466f17c3
Don't use mass-assignment protection when setting foreign keys or association conditions on singular associations. Fixes #481 (again).
2011-05-12 23:29:22 +01:00
Jon Leighton
1dd90f8f12
Don't use select() values from the join model of a through association. Fixes #508 .
2011-05-11 08:56:01 +01:00
Jon Leighton
a8c1fa4afd
Add test to specify that attributes from an association's conditions should be assigned without mass-assignment protection when a record is built on the association.
2011-05-10 23:35:15 +01:00
Christopher Meiklejohn
4fbd8adf48
Don't quote ID's as Arel will quote them -- follow same conventions as the delete method.
2011-05-08 18:37:28 +01:00
David Heinemeier Hansson
a8861c8f5b
Merge pull request #357 from joshk/assign_attributes.
...
Assign protected attributes with create/new and control the role.
2011-05-01 16:59:33 -07:00
Josh Kalderimis
86d7ed3375
singular and collection relations in AR can now specify mass-assignment security options (:as and :without_protection) in build, create and create! methods.
2011-05-01 23:30:07 +02:00
Josh Kalderimis
5164c50d7f
removed the default_scope deprecations and updated the docs and tests to reflect its use cases
2011-04-28 18:46:40 +02:00
Josh Kalderimis
a08d04bedf
Added assign_attributes to Active Record which accepts a mass-assignment security scope using the :as option, while also allowing mass-assignment security to be bypassed using :with_protected
2011-04-24 09:53:18 +02:00
Jon Leighton
019cd51a3f
Bring back support for passing a callable object to the default_scope macro. You can also just use a block.
2011-04-18 23:35:22 +01: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
256b363eee
Revert "Deprecate defining scopes with a callable (lambda, proc, etc) via the scope class method. Just define a class method yourself instead."
...
This reverts commit f0e198bfa1 .
Conflicts:
activerecord/test/models/post.rb
2011-04-17 20:47:52 +01:00
Aaron Patterson
1b5b53da5e
common @jonleighton 💣
2011-04-12 20:29:35 -07:00
Jon Leighton
f0e198bfa1
Deprecate defining scopes with a callable (lambda, proc, etc) via the scope class method. Just define a class method yourself instead.
2011-04-12 19:46:05 -07:00
Jon Leighton
8572ae6671
Evaluate default scopes at the last possible moment in order to avoid problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped.
2011-04-12 19:46:04 -07: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
9abc94c445
oracle, y u defy me
2011-03-16 18:54:34 +00:00
Jon Leighton
ddf83d14f1
Add a test for STI on the through where the through is nested, and change the code which support this
2011-03-05 20:10:24 +00: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
d90b4e2615
Rewrote AssociationPreload.
2011-02-28 22:12:34 +00:00
Jon Leighton
91fd651056
Allow building and then later saving has_many :through records, such that the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [ #4329 state:resolved]
2011-02-18 00:00:13 +00:00
Jon Leighton
f0b9805029
Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [ #6376 state:resolved]
2011-02-18 00:00:13 +00:00
Jon Leighton
a7e19b30ca
Add interpolation of association conditions back in, in the form of proc { ... } rather than instance_eval-ing strings
2011-02-14 01:40:31 +00:00
Jan
9643243204
make set_table_name take effect immediately
2011-02-08 10:31:09 -08:00
Jon Leighton
52f09eac5b
Correctly update counter caches on deletion for has_many :through [ #2824 state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business.
2011-02-07 23:35:05 +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
Edward Faulkner
909588d964
Fixing ordering of HABTM association deletion [ #6191 state:resolved]
...
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com >
2011-02-04 19:39:59 -02:00
Aaron Patterson
df07760486
introduce a fake AR adapter for mocking database return values
2011-02-04 13:34:57 -08:00
Aaron Patterson
ee34b4cf34
share column cache among subclasses, only look up columns per AR::Base subclass once
2011-02-01 14:25:46 -08:00
Glenn Vanderburg
6bd9fac1e3
Propagate association extensions to scopes called on the association.
...
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com >
2011-02-01 12:38:58 -02:00
Jon Leighton
3fa61ccb9e
Has many through - It is not necessary to manually merge in the conditions hash for the through record, because the creation is done directly on the through association, which will already handle setting the conditions.
2011-01-30 11:58:09 +00:00
Jon Leighton
63c73dd021
We shouldn't be using scoped.scoping { ... } to build associated records, as this can affect validations/callbacks/etc inside the record itself [ #6252 state:resolved]
2011-01-30 11:56:41 +00:00
Jon Leighton
bf24fe810c
belongs_to records should be initialized within the association scope
2011-01-16 13:43:53 -08:00
Jon Leighton
52c47556b7
Add create_association! for belongs_to
2011-01-16 13:43:53 -08:00
Jon Leighton
3b797c8c86
DRY up the code which instantiates the association proxy
2011-01-11 13:45:08 -08:00
Jon Leighton
c6e10b0f60
has_one should always remove the old record (properly), even if not saving the new record, so we don't get the database into a pickle
2011-01-11 13:45:06 -08:00
Ernie Miller
7d4d745730
Fix polymorphic belongs_to associationproxy raising errors when loading target.
2011-01-11 09:19:19 -08:00
Jon Leighton
770e6893b9
Construct an actual ActiveRecord::Relation object for the association scope, rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things.
2011-01-07 15:03:15 -08:00
Aaron Patterson
2efd780dcb
send() will raise an ArgumentError, so we should leverage ruby
2011-01-07 14:30:20 -08:00