Commit Graph

135 Commits

Author SHA1 Message Date
Pratik Naik
b77dd218ce Add Relation extensions 2010-04-02 17:38:02 +01:00
Andrew White
67d1cec4c8 Add the ability to specify table_name_prefix on individual modules
Signed-off-by: wycats <wycats@gmail.com>
2010-03-28 23:43:28 -07:00
Rizwan Reza
f1e5a9ff98 Add :dependent = to has_one and has_many [#3075 state:resolved] 2010-03-28 18:47:46 +04:30
Carlos Antonio da Silva
47d252f992 Fix associations to call :destroy or :delete based on the right :dependent option
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-03-09 00:11:34 +01:00
Henry Hsu
bf9a0ae12b Fix a bug where default_scope was overriding attributes given on model initialization [#3218 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-02-26 11:09:43 +01:00
Joshua Peek
db49c706b6 Axe AM state machine
We're going do it eventually, get it done before 3.0 is final.
2010-01-30 18:38:01 -06:00
Pratik Naik
8ff2fb6f3a Make default_scope work with Relations 2010-01-23 13:41:09 +05:30
Pratik Naik
9e7ec2a9f1 Simplify calculation scope building. Remove :order from associations as it is troublesome w/ calculation methods using postgresql. 2010-01-18 23:40:42 +05:30
Pratik Naik
d60bb0a9e4 Rename named_scope to scope 2010-01-18 04:38:19 +05:30
Pratik Naik
dca3de3bc7 Make relations work as scopes 2010-01-17 23:22:11 +05:30
Pratik Naik
f0cde5be54 Make sure named_scope names are not used as method names already 2010-01-17 21:34:41 +05:30
Eloy Duran
f2aacd5140 Rollback the transaction when one of the autosave associations fails to save. [#3391 state:resolved] 2010-01-08 21:45:02 +01:00
Bryan Stearns
1080351437 Add failing test that triggers the stack overflow 2010-01-08 21:45:02 +01:00
José Valim
8c5fe60ec8 Simplify repair_validations on AR and make it work with new callbacks. 2010-01-01 03:20:38 +01:00
Eloy Duran
c23fbd0d47 Refactored previous changes to nested attributes. 2009-12-28 21:09:22 +01:00
Murray Steele
ff508640e2 Make polymorphic_inverse_of in Reflection throw an InverseOfAssociationNotFoundError if the supplied class doesn't have the appropriate association. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:17 +01:00
George Ogata
81ca0cf2b0 Add inverse polymorphic association support. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 15:12:13 +01:00
Matt Jones
d625312fe1 delete correct records for a has_many with :primary_key and :dependent => :delete_all
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2009-11-10 18:41:37 +13:00
Eloy Duran
f125a34501 Define autosave association callbacks when using accepts_nested_attributes_for.
This way we don't define all the validation methods for all associations by
default, but only when needed.

[#3355 state:resolved]
2009-11-07 00:42:42 +01:00
Pratik Naik
572323135f Allow accepts_nested_attributes_for :reject_if option accept symbols for using a method
Conflicts:

	activerecord/lib/active_record/nested_attributes.rb
2009-10-07 23:50:30 +01:00
Luciano G Panaro
4168f87623 Make has_one with :conditions hash scope build or creation of the associated object with those conditions
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3088 state:committed]
2009-09-28 14:50:33 +13:00
Alexey Kovyrin
938c0ee045 Define autosave association validation methods only when needed. [#3161 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-09-12 16:04:36 +02:00
Graeme Porteous
c01be9de32 Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [#1756 state:resolved]
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-09-12 16:03:32 +02:00
Eloy Duran
6cc0b9638f Explicitely setting `autosave => false' should override new_record autosaving. [#2214 state:resolved]
Original author is Jacob.
2009-09-12 15:53:15 +02:00
Mike Breen
bcd0ef710e Raise an exception with friendlier error message when attempting to build a polymorphic belongs_to with accepts_nested_attributes_for. [#2318 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-09-12 15:37:54 +02:00
José Valim
2ea1d684d9 Refactor new callbacks and AR implementation.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
José Valim
4f37b97033 Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
railsbob
e06a0b03c8 has_many :through create should not raise validation errors
[#2934 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-09 18:44:45 -07:00
Tristan Dunn
0472839d68 Prevent overwriting of table name in merging SQL conditions [#2949 state:resolved] 2009-08-10 00:41:36 +01:00
Gabe da Silveira
00d6c76660 Enable has_many :through for going through a has_one association on the join model [#2719 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-10 00:30:44 +01:00
Rich Bradley
9bb8ef9ede Fix for nested :include with namespaced models.
[#260 state:committed]
2009-08-09 00:31:46 -07:00
Matt Duncan
3b3798506b Adding :from scoping to ActiveRecord calculations
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1229 state:committed]
2009-08-09 12:43:07 +12:00
Raimonds Simanovskis
090ec47bec added Subject#after_initialize to be the same as Topic#after_initialize 2009-08-06 23:41:00 +03:00
Raimonds Simanovskis
5666a3ad06 added :order option to find :first methods and associations as otherwise Oracle tests were failing
Oracle stores '' string as NULL
Oracle cannot have identifiers larger than 30 characters
added missing fixtures to test setup method
2009-08-06 23:40:59 +03:00
Joshua Peek
aad5a30bf2 Add simple support for ActiveModel's StateMachine for ActiveRecord 2009-08-04 11:03:57 -05:00
Jeremy Kemper
d83b182857 Revert "Methods invoked within named scope Procs should respect the scope stack. [#1267 state:resolved]"
This reverts commit 6a13376525.

Conflicts:

	activerecord/test/cases/named_scope_test.rb
2009-07-29 16:54:54 -07:00
Szymon Nowak
1c11437a32 Add primary_key option to belongs_to association
[#765 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-07-15 18:13:32 -07:00
Pratik Naik
45e6f19925 Revert "Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved]""
This reverts commit 80f1f863cd.

The feature doesn't work on Postgres, so don't test it on Postgres.
Also, Postgres compatibility is irrelevant to the ticket/patch in question.
2009-07-01 00:02:00 +01:00
Yehuda Katz + Carl Lerche
80f1f863cd Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved]"
This reverts commit 4851ca9e13.

The tests do not pass for postgresql.
2009-06-22 12:04:02 -07:00
Patrick Joyce
4851ca9e13 Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-06-21 22:07:23 +01:00
mattbauer
83c1934003 Ensure hm:t#create respects source associations hash conditions [#2090 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-06-21 17:35:04 +01:00
Joshua Peek
69742ca8fa Merge branch 'master' into active_model
Conflicts:
	activemodel/lib/active_model/core.rb
	activemodel/test/cases/state_machine/event_test.rb
	activemodel/test/cases/state_machine/state_transition_test.rb
	activerecord/lib/active_record/validations.rb
	activerecord/test/cases/validations/i18n_validation_test.rb
	activeresource/lib/active_resource.rb
	activeresource/test/abstract_unit.rb
2009-05-29 16:06:21 -05:00
Pratik Naik
c5e109bbe7 Make sure default_scope#create checks for options[:conditions] [#2181 state:resolved] [James Le Cuirot] 2009-05-18 21:27:42 +02:00
Benjamin Floering
27de7f150b Fixed limited eager loading associations with numbers in the name [#2668 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-05-18 13:56:17 +02:00
Jeremy Kemper
e8550ee032 Cherry-pick core extensions 2009-05-13 12:00:15 -07:00
Jeremy Kemper
ddbeb15a5e Revert "Fixed bug with polymorphic has_one :as pointing to an STI record"
[#2594 state:open]

This reverts commit 99c103be11.
2009-05-11 12:20:54 -07:00
Mike Breen
9010ed2755 Allow you to pass :all_blank to :reject_if option to automatically create a Proc that will reject any record with blank attributes. 2009-05-10 15:02:00 +12:00
Murray Steele
ccea98389a Providing support for :inverse_of as an option to associations.
You can now add an :inverse_of option to has_one, has_many and belongs_to associations.  This is best described with an example:

class Man < ActiveRecord::Base
  has_one :face, :inverse_of => :man
end

class Face < ActiveRecord::Base
  belongs_to :man, :inverse_of => :face
end

m = Man.first
f = m.face

Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again).  With these new :inverse_of options m and f.man are the same in memory instance.

Currently :inverse_of supports has_one and has_many (but not the :through variants) associations.  It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic.

Signed-off-by: Murray Steele <muz@h-lame.com>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-04 15:27:39 -07:00
Ruy Asan
99c103be11 Fixed bug with polymorphic has_one :as pointing to an STI record
[#2594 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-01 14:47:56 -07:00
Pratik Naik
5f3f100ce2 Merge branch 'master' into active_model
Conflicts:
	activeresource/lib/active_resource/validations.rb
2009-04-22 15:26:03 +01:00