Commit Graph

4270 Commits

Author SHA1 Message Date
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
Akira Matsuda
817e370136 Make before_type_cast available for datetime fields
[#3973 state:committed]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-02-01 12:21:18 -02:00
Aaron Patterson
4ccf8319bb expand mulasgn for enhancing readability 2011-01-31 14:03:28 -08:00
John Firebaugh
57bc25c5f8 Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Pratik Naik
30176f28a4 Add :bulk => true option to change_table 2011-01-31 13:21:25 +00:00
Jon Leighton
9db4c07e0b Make use of helpers in AssociationReflection 2011-01-30 11:58:09 +00: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
c5e912a8b3 @join_table_name is no longer used 2011-01-30 11:58:09 +00:00
Jon Leighton
59d54c3eba Make AssociationCollection#include? a bit more readable 2011-01-30 11:58:08 +00:00
Jon Leighton
0645fd2c80 Don't use method_missing when we don't have to 2011-01-30 11:58:08 +00:00
Jon Leighton
2e24cf7cc2 AssociationCollection#clear can basically just use #delete_all, except it should return self. 2011-01-30 11:58:08 +00:00
Jon Leighton
88df88095c AssociationCollection#to_ary should definitely dup the target! Also changed #replace which was previously incorrect, but the test passed due to the fact that to_a was not duping. 2011-01-30 11:58:08 +00:00
Jon Leighton
1da1ac159f Just use primary_key here, AR::Relation will resolve the ambiguity before it is converted to SQL 2011-01-30 11:58:08 +00:00
Jon Leighton
140b269fb7 Call sum on the scope directly, rather than relying on method_missing and calculate 2011-01-30 11:58:08 +00:00
Jon Leighton
ca7785847e Condense first_or_last a bit more 2011-01-30 11:58:08 +00:00
Jon Leighton
fdee153ff8 Get rid of separate reset_target! and reset_scopes_cache! methods 2011-01-30 11:58:08 +00:00
Jon Leighton
5dd3dadcdd target is always an array 2011-01-30 11:58:08 +00:00
Jon Leighton
47309826e4 load_target will return the target. it also will not load if loaded? is true. 2011-01-30 11:58:08 +00:00
Jon Leighton
b7bcc7e190 DRY up first/last and hence make last benefit from the bugfix in first 2011-01-30 11:58:08 +00:00
Jon Leighton
e8d7152a89 Use scoped.find directly rather than having a find_by_sql method 2011-01-30 11:58:07 +00:00
Jon Leighton
1a4bbaf106 Use scoped.first and scoped.last instead of find(:first, ...) and find(:last, ...) 2011-01-30 11:58:07 +00:00
Jon Leighton
1e7cf6c7e9 Try to make fetch_first_or_last_using_find? more readable 2011-01-30 11:58:07 +00:00
Jon Leighton
db503c4142 load_target returns the target 2011-01-30 11:56:41 +00:00
Jon Leighton
aa86420be2 Rename AssociationProxy#loaded to loaded! as it mutates the association 2011-01-30 11:56:41 +00:00
Jon Leighton
de05e2fb15 Abstract load_target conditional logic 2011-01-30 11:56:41 +00:00
Jon Leighton
d392c67d2c Remove unused methods conditions, sql_conditions and sanitize_sql 2011-01-30 11:56:41 +00:00
Jon Leighton
dbb6fa723e Don't pass around conditions as strings in ThroughAssociation 2011-01-30 11:56:41 +00:00
Jon Leighton
d85ee50eda Indent methods under private/protected sections 2011-01-30 11:56:41 +00:00
Jon Leighton
15601c52e7 Let's be less blasé about method visibility on association proxies 2011-01-30 11:56:41 +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
Aaron Patterson
740bc35d32 always return the identity function from type_cast_code 2011-01-28 18:04:22 -08:00
Aaron Patterson
72c1818941 use an identity conversion to avoid conditional codes 2011-01-28 17:39:38 -08:00
Alexey Nayden
e92c2ffd8e Nested attributes and in-memory changed values #first and #[] behaviour consistency fix 2011-01-28 15:06:01 -08:00
Aaron Patterson
59f3218463 load and prefer psych as the YAML parser when it is available 2011-01-21 17:53:28 -08:00
Xavier Noria
236f1f52cd Merge branch 'master' of git://github.com/lifo/docrails 2011-01-20 10:33:38 +01:00
Aaron Patterson
a282301a77 we have a method for setting preloaded records, so use it 2011-01-18 16:33:18 -08:00
Aaron Patterson
c107849a99 reduce objects, reduce loops and function calls while building the conditional 2011-01-18 15:52:57 -08:00
Aaron Patterson
f3a5995bbf keys will always be strings in the id => record map 2011-01-18 15:52:57 -08:00
Aaron Patterson
9e42f1b416 reduce method calls and loops when dealing with custom conditions 2011-01-18 15:52:57 -08:00
Aaron Patterson
ba62a87b8b ony bother with record map keys when we need them 2011-01-18 15:52:57 -08:00
Aaron Patterson
4bc9bacd94 refactor elaborate group_by in to a normal group_by 2011-01-18 15:52:57 -08:00
Aaron Patterson
11fe2161ce remove unnecessary module_eval 2011-01-18 09:36:33 -08:00
Aaron Patterson
9d549986dd remove useless conditional 2011-01-17 16:42:34 -08:00
Jaime Iniesta
4b7dad2df3 ActiveRecord#save(false) is now deprecated, now it is save(:validate => false) 2011-01-18 00:35:07 +01:00
Jon Leighton
d1521719c5 Removed support for accessing attributes on a has_and_belongs_to_many join table. This has been documented as deprecated behaviour since April 2006. Please use has_many :through instead. A deprecation warning will be added to the 3-0-stable branch for the 3.0.4 release. 2011-01-16 13:43:54 -08:00
Jon Leighton
c4458b3602 Rename some variables 2011-01-16 13:43:54 -08:00
Jon Leighton
8aedd722e1 Use self.target= in HasOneThroughAssociation too 2011-01-16 13:43:54 -08:00
Jon Leighton
b7594a0756 find_target can also go into SingularAssociation 2011-01-16 13:43:53 -08:00
Jon Leighton
f1a15c2197 Abstract a bit more into SingularAssociation 2011-01-16 13:43:53 -08:00
Jon Leighton
115eedbb41 Use self.target= rather than @target= as the former automatically sets loaded 2011-01-16 13:43:53 -08:00