lukeludwig
3ee4e00918
Cache columns for has_and_belongs_to_many associations
...
This avoids repeatedly calling SHOW COLUMNS when the association is queried
[#1738 state:committed]
2009-01-17 18:09:13 +13:00
Roman Shterenzon
21efba464a
Fix HasManyAssociation#create ignoring the :primary_key option [ #1633 state:resolved]
...
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com >
2008-12-27 01:10:29 +00:00
Karthik Krishnan
75a133f92f
Fix has many through not quoting table names [ #1163 state:resolved]
...
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com >
2008-12-20 21:08:51 +00:00
Matt Jones
a9422cc1db
Fix preloading of has_one :through associations on belongs_to [ #1507 state:resolved]
...
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com >
2008-12-18 19:19:36 +00:00
Jeremy Kemper
b30ae19748
Revert "Fix: counter_cache should decrement on deleting associated records."
...
[#1196 state:open]
This reverts commit 05f2183747 .
2008-12-10 14:48:12 -08:00
Emilio Tagua
05f2183747
Fix: counter_cache should decrement on deleting associated records.
...
[#1195 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-12-10 10:59:52 -08:00
Mike Ferrier
566a3dce67
Make NoMethodError message more descriptive when an undefined message has been sent to an association [ #1515 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2008-12-04 13:31:18 -06:00
miloops
97403ad5fd
Add :having option to find, to use in combination with grouped finds. Also added to has_many and has_and_belongs_to_many associations.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1028 state:committed]
2008-12-01 20:22:31 +01:00
Matt Jones
d3fd997109
fix assignment to has_one :through associations.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-11-15 18:20:39 +01:00
Pratik Naik
a03e2b356c
Merge with docrails. Also add a rake task to generate guides in your rails application :
...
rake doc:guides
The rake task will generate guides inside doc/guides directory of your application. Open index.html to browse.
2008-10-21 18:33:40 +01:00
Pratik Naik
95c609357e
Ensure association proxy responds to private class methods defined in associated class. [ #1083 ]
2008-10-16 23:17:49 +02:00
Ian White
517bc500ed
Allow class methods to be sent (via #send) to association proxy (fix for bug introduced by 691aa20) [ #1083 ]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-10-16 10:41:48 +02:00
Pratik Naik
691aa20280
Ensure methods called on association proxies respect access control. [ #1083 state:resolved] [Adam Milligan, Pratik]
2008-10-13 19:02:34 +02:00
Zach Dennis
95e1cf4812
Fix has_many :through when the source is a belongs_to association. [ #323 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-10-04 17:49:39 +01:00
Lawrence Pit
7659fb6a2b
Try reloading model on class mismatch [ #229 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-10-04 17:49:38 +01:00
Hongli Lai (Phusion)
70b8ea4fa6
Make AssociationCollection start transactions in the correct database.
...
AssociationCollection now starts transactions by calling
AssociationCollection#transaction instead of @owner.transaction or
@reflection.klass.transaction.
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1081 state:committed]
2008-09-23 20:32:01 +02:00
Jan De Poorter
050e58441b
Association#first and last should not load the association if not needed. [ #1091 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-09-22 18:22:30 +01:00
Michael Koziarski
4db7e8de11
Update the documentation to reflect the change handling :group earlier
2008-09-16 18:50:36 +02:00
miloops
dc8bf7515d
When counting grouped records the target should be loaded to return a valid groups count result.
...
Without this change count_records will group for the count in the query and return erroneous results.
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#937 state:committed]
2008-09-15 18:32:05 +02:00
Pratik Naik
9994f0d902
Revert "Add :accessible option to Associations for allowing mass assignments using hash. [ #474 state:resolved]"
...
This reverts commit e0750d6a5c .
Conflicts:
activerecord/CHANGELOG
activerecord/lib/active_record/associations.rb
activerecord/lib/active_record/associations/association_collection.rb
2008-09-10 18:50:01 +01:00
Hongli Lai (Phusion)
1398db0128
Add special AssociationReflection methods for creating association objects, and modify the code base to use those methods instead of creating association objects directly. This allows plugins to hook into association object creation behavior.
...
[#986 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-09-09 13:13:12 -07:00
Pratik Naik
6ef35461dc
Merge docrails
2008-09-03 17:58:47 +01:00
Ernie Miller
44af2efa2c
Refactored AssociationCollection#count for uniformity and Ruby 1.8.7 support.
...
[#831 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-28 11:58:25 -07:00
Tarmo Tänav
96c6fe0842
Implement count limit/offset support for has_many associations
...
[#348 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-27 23:32:21 -07:00
Jeremy Kemper
a444c78212
respond_to? passes along splat args to avoid introducing the second arg if it was omitted
2008-08-27 21:32:51 -07:00
pivotal
9dbde4f5cb
Fix two has_one :through errors
...
* Set the association target on assignment;
* Reset target to nil on reset, rather than empty array.
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#895 state:committed]
2008-08-27 11:22:15 +02:00
Jeremy Kemper
c471f13db6
Ruby 1.9 compat: Hash is now flattenable, so explicitly exclude it
2008-08-23 21:26:14 -07:00
Xavier Noria
a970f916fb
Fix has_many#count_records. [ #865 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-08-21 15:48:04 +01:00
Jakub Kuźma
ea40f71431
Fix that has_one natural assignment to already associated record. [ #854 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-08-21 15:21:21 +01:00
Nathan Witmer
8cfdcdb35d
Updated has_and_belongs_to_many association to fix :finder_sql interpolation. [ #848 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-08-16 22:23:48 +01:00
Tarmo Tänav
b3c9d53b34
Use type_condition method for hmt STI condition
2008-08-15 15:57:33 -07:00
Ernie Miller
7f6e7ba1f7
Fixed AssociationCollection#<< resulting in unexpected values in @target when :uniq => true
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-08-08 15:19:08 +02:00
Tarmo Tänav
656f0e7c6c
Fix file permissions
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2008-07-31 16:36:23 -05:00
David Dollar
e0750d6a5c
Add :accessible option to Associations for allowing mass assignments using hash. [ #474 state:resolved]
...
Allows nested Hashes (i.e. from nested forms) to hydrate the appropriate
ActiveRecord models.
class Post < ActiveRecord::Base
belongs_to :author, :accessible => true
has_many :comments, :accessible => true
end
post = Post.create({
:title => 'Accessible Attributes',
:author => { :name => 'David Dollar' },
:comments => [
{ :body => 'First Post!' },
{ :body => 'Nested Hashes are great!' }
]
})
post.comments << { :body => 'Another Comment' }
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-07-14 02:53:21 +01:00
Jason Dew
c6f397c5ce
Add block syntax to HasManyAssociation#build. [ #502 state:resolve]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-07-14 02:24:12 +01:00
Cheah Chu Yeow
ce4a1bb853
Remove some Symbol#to_proc usage in runtime code. [ #484 state:resolved]
2008-07-09 10:42:30 -07:00
Brad Greenlee
afa0c7f728
Add support for :primary_key option to has_one as well as has_many so that a key other than the default primary key can be used for the association
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-07-06 20:25:10 +02:00
Andre Arko
3351d29970
Add has_many :primary_key option to allow setting the primary key on a has many association
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-07-06 20:25:10 +02:00
Pratik Naik
474d425382
Ensure AssociationCollection#size considers all unsaved record. [ #305 state:resolved] [sds]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-07-02 03:17:33 +01:00
Pratik Naik
5ca7d01eca
Cache sanitized conditions in reflection object for associations
2008-06-27 02:47:38 +01:00
Andre Arko
0b12da44aa
Extract owner_quoted_id so it can be overridden. [ #292 state:committed]
2008-06-25 19:04:09 -07:00
Brandon Keepers
e94e53f9cd
fix eager loading with dynamic finders
2008-06-09 12:05:20 -04:00
rick
72483c0d4c
Add ActiveRecord::Base.sti_name that checks ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [rick] [ #114 state:resolved]
2008-05-31 17:13:11 -07:00
Tim Harper
0580b31b36
belongs_to polymorphic association assignments update the foreign_id and foreign_type fields regardless of whether the record being assigned is new or not.
...
fixes the following scenarios:
* I have validates_inclusion_of on the type field for a polymorphic belongs_to association. I assign a new record to the model's polymorphic relationship of the proper type. validation fails because the type field has not been updated.
* I replace the value for a ppolymorphic association to a new record of another class. The type field still says its the previous class, and the id field points to the previous record as well.
[#191 state:closed]
2008-05-31 13:27:25 -07:00
Pratik Naik
abb1bd2efa
Ensure AssociationCollection#count works with empty condition. [ #271 state:resolved] [Jan De Poorter]
2008-05-29 10:20:39 +01:00
Pratik Naik
98dc582742
Merge docrails.
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-05-25 12:29:00 +01:00
Ryan Bates
6cba97d2a4
Create through associations can now work with blocks.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#248 state:resolved]
2008-05-24 18:26:13 +12:00
josevalim
8d0b4fa39f
Added :select option to has_one and belongs_to, remove unused :order option on belongs_to.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#241 state:resolved]
2008-05-24 17:58:03 +12:00
Pratik Naik
19d7b1d22b
Verbose ActiveRecord::AssociationTypeMismatch exception message. [ #189 state:resolved]
2008-05-21 10:46:28 +01:00
Ryan Bates
73c5963854
Add first/last methods to associations/named_scope. [ #226 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-05-20 12:27:14 +01:00