10315 Commits

Author SHA1 Message Date
Eloy Duran
3d17d79bbf Removed unnecessary call to #try and cleaned up a bit more. 2010-01-07 13:20:42 +01:00
Eloy Duran
4b7a439bd1 Don't use strings for callbacks, as these will be evaled. Rather use symbols, which uses a direct method dispatch.
Patch by Comron Sattari. [#3429 state:resolved]
2010-01-07 13:20:42 +01:00
Eloy Duran
c48a71c7e4 Cleanup some code in nested_attributes.rb, autosave_association.rb, and associations.rb with AssociationReflection#collection_association?
Also cache the result value.
2010-01-07 13:20:42 +01:00
Eloy Duran
f12dd62d47 Add AssociationReflection#collection_association? which returns true if it's for a has_many or has_and_belongs_to_many association. 2010-01-07 13:20:42 +01:00
Eloy Duran
e20ac99026 Refactored nested attributes a bit after last commit. 2010-01-07 13:20:42 +01:00
Mike Breen
69db137f89 Allows you to pass :all_blank to :reject_if option to automatically create a Proc that will reject any record with blank attributes.
[#2501 state:resolved]

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2010-01-07 13:20:41 +01:00
José Valim
b7fd42626a Use helpers.label instead of views.labels. 2010-01-07 02:28:10 +01:00
José Valim
319e4aa263 Make ActionPack specs work when I18n 0.3.3 is installed as gem. 2010-01-05 00:27:50 +01:00
Hongli Lai (Phusion)
1012dec88f The failsafe middleware should flush the logger upon logging the error, otherwise nothing will be written to the log file.
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2010-01-05 10:39:42 +13:00
Zach Brock
f32c96eb76 fixing autolinking other protocols
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#3494 state:committed]
2010-01-05 10:39:12 +13:00
Stefan Penner
c362a76d00 Fixed multiparameter attribute assignment bug RE: Ticket 3131
http://rails.lighthouseapp.com/projects/8994/tickets/3131-multiparamter_attribute-assignment-fails-when-used-via-assoication
2010-01-02 23:48:09 -08:00
Stefan Penner
b3dd14adbe Failing test case RE: Ticket 3131
http://rails.lighthouseapp.com/projects/8994/tickets/3131-multiparamter_attribute-assignment-fails-when-used-via-assoication
2010-01-02 23:48:08 -08:00
Carsten Gehling
f5714abc3d I18n label helper [#745 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-01-02 23:38:01 +01:00
Willem van Bergen
37c51594b9 Added two SAX-based backends for XmlMini, using both LibXML and Nokogiri.
[#3636]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-01-01 13:18:43 -08:00
Willem van Bergen
12f6fd0f26 Bugfixes, speed improvements and code cleanup for Nokogiri's and LibXML's XmlMini backend
[#3641]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-01-01 13:17:02 -08:00
Jeremy Kemper
54bc4852ea Fix pg test 2009-12-28 13:05:44 -08:00
Eloy Duran
90f001ba39 Refactored previous changes to nested attributes. 2009-12-28 21:08:20 +01:00
Michael Siebert
7074c5a629 Add an :update_only option to accepts_nested_attributes_for for to-one associations. [#2563 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 19:02:01 +01:00
Eloy Duran
146a750568 Make sure to not add autosave callbacks multiple times. [#3575 state:resolved]
This makes sure that, in a HABTM association, only one join record is craeted.
2009-12-28 16:46:48 +01:00
Murray Steele
3470b306bb 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 14:21:42 +01:00
Murray Steele
603b28c84c Provide a slightly more robust we_can_set_the_inverse_on_this? method for polymorphic belongs_to associations. [#3520 state:resolved]
Also add a new test for polymorphic belongs_to that test direct accessor assignment, not just .replace assignment.

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 14:21:18 +01:00
George Ogata
cca75ca23f Add inverse polymorphic association support. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 14:20:58 +01:00
Murray Steele
592085be83 Add more tests for the various ways we can assign objects to associations. [#3513 state:resolved]
Get rid of a duplicate set_inverse_instance call if you use new_record(true) (e.g. you want to replace the existing instance).

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 14:20:33 +01:00
George Ogata
ed5b89483a Set inverse for #replace on a has_one association. [#3513 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 14:18:46 +01:00
Frederick Cheung
ab09ffd41e honour :inverse_of for joins based include
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 13:32:04 +01:00
Frederick Cheung
894c9b112c honour inverse_of when preloading associations
Signed-off-by: Michael Koziarski <michael@koziarski.com>
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
2009-12-28 13:31:29 +01:00
David Heinemeier Hansson
1684aa113e Fix tests 2009-12-27 15:23:51 -08:00
David Heinemeier Hansson
2675e4ef83 Translated strings in the view are assumed html_safe (Closes #3401) 2009-12-24 20:33:25 -08:00
Dwayne Litzenberger
a900205676 Fix ActiveSupport::JSON encoding of control characters [\x00-\x1f]
According to RFC 4627, only the following Unicode code points are
allowed unescaped in JSON:

  unescaped = %x20-21 / %x23-5B / %x5D-10FFFF

However, ActiveSupport::JSON did not escape the range %x00-1f.  This caused
parse errors when trying to decode the resulting output.

[#3345 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-23 11:46:25 -08:00
Murray Steele
5374fb3cad 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: Michael Koziarski <michael@koziarski.com>
Signed-off-by: José Valim <jose.valim@gmail.com>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>

Conflicts:

	activerecord/lib/active_record/associations/belongs_to_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
2009-12-21 13:13:32 -08:00
David Heinemeier Hansson
8bb3b9bcff Models with no attributes should just have empty hash fixtures [Sam] (Closes #3563) 2009-12-17 17:53:33 -08:00
David Heinemeier Hansson
e6cadd422b Added :alert, :notice, and :flash as options to ActionController::Base#redirect_to that'll automatically set the proper flash before the redirection [DHH] Added ActionController::Base#notice/= and ActionController::Base#alert/= as a convenience accessors in both the controller and the view for flash[:notice]/= and flash[:alert]/= [DHH] 2009-12-17 11:34:47 -08:00
David Heinemeier Hansson
48cd7dfcf8 Fix the app generator of cookie_verification_secret.rb 2009-12-16 14:06:20 -08:00
José Valim
1c3711b21b Fix another regression due to the inclusion of ActiveRecord::Error.
If a string is supplied to :default, it should not be used a
translation key (we already have :message for that).
[#3564 status:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-12-16 14:18:46 -06:00
Will
b1bbf90dff When passing force_reload = true to an association, don't use the query cache [#1827 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-12-16 10:49:40 -06:00
David Heinemeier Hansson
1229ef7bf3 Accessing nonexistant cookies through the signed jar should not raise an exception 2009-12-15 21:27:38 -08:00
David Heinemeier Hansson
6d1494cec6 Its cookie_verifier_secret 2009-12-15 21:03:57 -08:00
David Heinemeier Hansson
0200e20f14 Added cookies.permanent, cookies.signed, and cookies.permanent.signed accessor for common cookie actions [DHH] 2009-12-15 20:01:48 -08:00
Geoff Buesing
e4ebaab1cb Add test for TimeWithZone#to_i with wrapped DateTime 2009-12-15 08:41:57 -06:00
Serguei Filimonov
754bbaaf37 Added #to_i to DateTime in ActiveSupport so #to_yaml works correctly on ActiveRecord models with DateTime attributes. 2009-12-15 08:34:02 -06:00
David Heinemeier Hansson
f039bbb13e Dont be an ass and leave merge shit in stable, please 2009-12-14 18:07:37 -08:00
David Heinemeier Hansson
fda3ac6e68 Add Enumerable#exclude? to bring parity to Enumerable#include? and avoid if !x.include?/else calls [DHH] 2009-12-14 18:01:47 -08:00
John Pignata
1d9468b44e Fix postgresql AR test failure
Due to the ordering of the returning result set, the test fails under the postgresql adapter. Order results by id prior to checking the first item

[#3542 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-11 15:15:37 -06:00
Jeremy Kemper
b9f352316e Ruby 1.9.2: exclude to_str from explicit coercion check too 2009-12-06 16:54:53 -08:00
Jeremy Kemper
64082b350c Ruby 1.9.2: explicitly raise NoMethodError for attempts at explicit coercion 2009-12-06 16:46:01 -08:00
Jeremy Kemper
b92ff78df6 Ruby 1.9: don't rely on . in load path 2009-12-06 15:34:13 -08:00
Gabe da Silveira
43d2cb8e93 Replace reset_counter_cache with reset_counters that has API inline with existing update_counters method
[#1211 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-03 23:25:41 -08:00
Ben Marini
ccb197b2e6 Add support for Mysql column positioning via #add_column and #change_column
add_column and change_column in the Mysql adapter now accept some
additional options:
:first => true        # Put the column in front of all the columns
:after => column_name # Put the colmn after 'column_name'

add_column :new_col, :string, :first => true
add_column :another_col, :integer, :default => 0, :after => :new_col

[#3286 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-03 23:10:35 -08:00
Michael Koziarski
c253d7b2db 1.9 Fix for exception views. 2009-12-03 10:27:11 +13:00
Mat Brown
2f1ded3067 Fix instance_eval calls to association proxies
In the current stable, ActiveRecord::Associations::AssociationProxy#method_missing calls yield() if a block is given, causing the block to always be evaluated in its calling context. However, in the case of instance_eval, correct behavior requires that the block be passed directly to the @target, rather than being evaluated inside a different block. Incidentally, this also simplifies the code slightly.

[#3412 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-12-02 12:46:36 -08:00