Ben VandenBos
0e92f67073
Make belongs_to :dependent => :destroy destroy self before associated object [ #1079 state:resolved]
...
If foreign key constraints are in place then deleteing the associated object first will cause a foreign key violation
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com >
2009-01-16 17:23:19 +00:00
Pratik Naik
82443ecfad
Merge commit 'fred/pullable'
2008-12-30 17:50:17 +00:00
Xavier Noria
a2270ef259
Inline code comments for class_eval/module_eval [ #1657 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-12-28 19:49:28 +00:00
Frederick Cheung
afdec83ed5
Fix to_sentence being used with options removed by 273c77
2008-12-27 14:16:17 +00:00
Frederick Cheung
7db1704068
Fix :include of has_many associations with :primary_key option
2008-12-26 23:17:56 +00:00
Frederick Cheung
b17b9371c6
Fix configure_dependency_for_has_many not quoting conditions properly [ #1461 state:resolved]
2008-12-21 15:57:48 +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
Pratik Naik
c3f53f412c
Merge docrails
2008-12-19 14:27:43 +00:00
Frederick Cheung
9c7fe7c672
Don't include table_name twice
2008-12-18 19:19:36 +00:00
Frederick Cheung
c9ab7098be
Ensure :include checks joins when determining if it can preload [ #528 state:resolved]
2008-12-18 19:19:36 +00: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
Paul
9a4d557713
Ensure hash conditions on referenced tables are considered when eager loading with limit/offset. [ #1404 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-11-26 15:25:39 +01:00
Joshua Peek
7254d23764
Autoload ActiveRecord files
2008-11-24 11:14:24 -06:00
Tekin Suleyman
26978e3ce8
Added :counter_sql as a valid key for habtm associations
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-11-07 07:50:23 +00:00
Pratik Naik
dc37fdc480
Merge docrails. Remove unnecessary files.
2008-11-02 18:13:54 +05:30
Luca Guidi
5229fc4cc0
Make sure habtm use class variable to list association valid keys
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1310 state:committed]
2008-11-01 15:04:08 +01:00
Jeremy Kemper
838cb1aa50
Skip collection ids reader optimization if using :finder_sql
2008-10-23 18:53:44 -07: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
Michael Koziarski
cb45ee344d
Remove the functionality introduce in 28d3390
...
There are several situations it doesn't cater for, and the inconsistency isn't worth blocking 2.2.
2008-10-10 17:04:46 +02:00
Will Bryant
4c05055487
explicitly including child associations that are also included in the parent association definition should not result in double records in the collection/double loads ( #1110 )
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1110 state:committed]
2008-10-10 16:58:39 +02:00
Pratik Naik
a2932784bb
Merge docrails
2008-10-05 22:16:26 +01:00
Hongli Lai (Phusion)
72b772ae9b
Refactor configure_dependency_for_has_many to use a few more methods.
...
Add an additional conditions option to make it slightly easier for certain plugins.
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#1087 state:committed]
2008-09-24 13:27:39 +02:00
Hongli Lai (Phusion
46939a9b5a
Add Model#delete instance method, similar to Model.delete class method. [ #1086 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-09-21 22:53:44 +01:00
Adeh DeSandies
de96a8666d
applied patch to fix the associations with blocks in modules bug from an old trac ticket
2008-09-20 13:46:09 -07:00
Nathaniel Talbott
9d7f186f74
Fixed an error triggered by a reload followed by a foreign key assignment.
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
2008-09-20 14:16:43 +02:00
Jon Leighton
fcf31cb752
Support for updating a belongs to association from the foreign key (without saving and reloading the record)
...
Signed-off-by: Michael Koziarski <michael@koziarski.com >
[#142 state:committed]
2008-09-13 11:08:29 +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
Hongli Lai (Phusion)
1692940441
Make the options that has_many, belongs_to and other association generation methods can accept, configurable.
...
[#985 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-09-09 12:50:32 -07:00
Pratik Naik
6ef35461dc
Merge docrails
2008-09-03 17:58:47 +01:00
Clemens Kofler
ba3ecf53b4
Some performance goodness for AR associations.
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-09-03 00:55:22 +02:00
miloops
6183e55f71
Use reflection primary_key instead of id for when selecting association ids.
...
[#906 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-30 17:39:30 -07:00
miloops
b163d83b8b
Performance: Better query for ASSOCIATION_ids. Select only ids if the association hasn't been loaded.
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-30 15:24:09 -07:00
Andrew White
db22c89543
Merge scoped :joins together instead of overwriting them. May expose scoping bugs in your code!
...
[#501 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-28 12:07:15 -07: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
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
Tarmo Tänav
a445cdd884
Load the first and not the last has_one result when doing join-based eager loading
...
This matters when the has_one is defined with an order in which case
there is an expectation that the first one will be loaded.
[#904 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-25 21:23:35 -07:00
Frederick Cheung
2dbda11945
Implement old-skool eagerloading for has_one :through
...
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2008-08-25 21:23:15 -07:00
Peter Wagenet
8622787f87
Don't interpret decimals as table names in ActiveRecord::Associations::ClassMethods#references_eager_loaded_tables? [ #532 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-08-21 17:21:17 +01:00
Tarmo Tänav
2b69a636c4
Fixed STI type condition for eager loading of associations
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-08-16 20:41:19 +01:00
Tarmo Tänav
656f0e7c6c
Fix file permissions
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2008-07-31 16:36:23 -05:00
Pratik Naik
6e75455125
Merge docrails changes
2008-07-28 12:33:24 +01:00
Daniel Guettler
c67713a2fe
Use klass.sti_name to make sure associations take store_full_sti_class into account. [ #671 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-07-22 01:24:47 +01:00
Pratik Naik
0432d15164
Merge with docrails.
2008-07-16 13:01:23 +01:00
Tarmo Tänav
8c91b767c0
Fixed postgresql limited eager loading for the case where scoped :order was present
2008-07-14 22:44:58 -07: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
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
Jan De Poorter
b2b761166d
Make sure associated has_many/habtm objects get saved even when :validate => false is used. [ #486 state:resolved]
...
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2008-06-27 03:02:13 +01:00