Commit Graph

26 Commits

Author SHA1 Message Date
Pratik Naik
d511de0261 Add find_or_create_by_* and find_or_initialize_by_* to relations 2009-12-27 14:28:19 +05:30
Pratik Naik
f6f416c58e Add find_by_* and find_all_by_* finders to ActiveRecord::Relation 2009-12-27 03:25:29 +05:30
Pratik Naik
c6258ee313 Ensure all the finder methods respect scoping 2009-12-26 19:15:05 +05:30
Pratik Naik
9a9f97af28 Add relation.reload to force reloading the records 2009-12-26 15:31:50 +05:30
Pratik Naik
3c5a7dcaf5 Cache the loaded relations 2009-12-26 15:07:00 +05:30
Pratik Naik
9d3d60c64a Ensure preload and eager_load finder methods accept multiple arguments 2009-12-26 14:40:45 +05:30
Pratik Naik
187fbe5cba Add support for multiple arguments to .where finder 2009-12-26 12:57:34 +05:30
Pratik Naik
feb8b20eb5 Add Relation#all as an alias for to_a 2009-12-26 12:39:44 +05:30
Pratik Naik
95274b28d9 Rename Model.conditions and relation.conditions to .where 2009-12-26 03:50:57 +05:30
Pratik Naik
1a99337180 No parentheses for assert_equal 2009-12-26 03:10:55 +05:30
Pratik Naik
a7fd564ab1 Add Model.select/group/order/limit/joins/conditions/preload/eager_load class methods returning a lazy relation.
Examples :

    posts = Post.select('id).order('name') # Returns a lazy relation
    posts.each {|p| puts p.id } # Fires "select id from posts order by name"
2009-12-26 03:06:51 +05:30
Pratik Naik
2e79ec71a5 Model.scoped now returns a relation if invoked without any arguments
Example :

    posts = Post.scoped
    posts.size # Fires "select count(*) from  posts" and returns the count
    posts.each {|p| puts p.name } # Fires "select * from posts" and loads post objects
2009-12-26 01:33:20 +05:30
Jeremy Kemper
703d31c20a Clarify failed assertion 2009-11-09 17:01:57 -08:00
Emilio Tagua
9a958a3d7d Relations: Added offset when finding with associations. Delegate array instance
methods to to_a.
2009-10-07 12:43:04 -03:00
Emilio Tagua
1d5854826b Allow preload and eager_load to work on relations at the same time. 2009-10-07 11:57:59 -03:00
Emilio Tagua
3747f896a1 Moved relation's test to relation_test. 2009-10-05 14:39:20 -03:00
Emilio Tagua
c01c21b31d Added association preload to relation. 2009-09-01 15:36:09 -03:00
Emilio Tagua
6b67df70ab Revert "Revert "Add readonly support for relations.""
This reverts commit f2c0725d79e29b02e30e7a4827851acc4a766730.
2009-08-27 20:03:46 -03:00
Emilio Tagua
f2c0725d79 Revert "Add readonly support for relations."
This reverts commit 7cce95b25ace33e04526d4490e487a080c1f9b96.
2009-08-27 20:00:14 -03:00
Emilio Tagua
7cce95b25a Add readonly support for relations. 2009-08-27 18:52:14 -03:00
Emilio Tagua
74ed123e08 Override respond_to? in ActiveRecord::Relation to go with
method_missing.
2009-08-18 16:35:33 -03:00
Emilio Tagua
66fbcc1de6 Use immutable relation objects to generate queries. 2009-08-18 14:10:03 -03:00
Emilio Tagua
08f6af2d53 Fix typo in test classname. 2009-08-18 08:12:35 -03:00
Emilio Tagua
79e951ca9b Use finder options as relation method names to provide more familiar
naming. Use bang methods convention in methods that alter the
relation.
2009-08-18 07:50:11 -03:00
Emilio Tagua
f8eb4434d6 Added collection iteration to AR::Relation. 2009-08-03 14:15:47 -03:00
Emilio Tagua
c1cbf02e31 Added ActiveRecord::Relation tests. Allow Relation to accept conditional
hashes and arrays like #find does.
2009-07-31 16:08:22 -03:00