Commit Graph

2758 Commits

Author SHA1 Message Date
Bryan Helmkamp
a2875bec9a Use DependencyModule for included hooks in ActiveRecord 2009-05-11 22:23:47 -04: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
Anthony Crumley
026b78f907 Fixed eager load error on find with include => [:table_name] and hash conditions like {:table_name => {:column => 'value'}}
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2009-05-10 13:36:51 +12:00
Frederick Cheung
235775de29 honour :inverse_of for joins based include
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2009-05-10 12:50:03 +12:00
Frederick Cheung
ef6f22ab2a honour inverse_of when preloading associations
Signed-off-by: Michael Koziarski <michael@koziarski.com>
2009-05-10 12:50:02 +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
Chris Kampmeier
d3ee8756c8 Don't use #tap before Active Support is available, since older versions of ruby don't have native implementations
[#2603 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-04 08:32:25 -07:00
Jeremy Kemper
945bf9c254 Check for sibling Active Support first 2009-05-02 15:16:12 -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
Alexander Podgorbunsky
db0bfe4ede Default scope :order should be overridden by named scopes.
[#2346 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-05-01 14:44:24 -07:00
steve
60a6284a46 Tests should use ActiveRecord::Base.connection.rollback_db_transaction to rollback a transaction
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-05-01 16:00:09 +01:00
steve
5501b99a19 Ensure ActiveRecord::Base.connection_pool.with_connection creates a new connection only when needed [#1752 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-05-01 14:58:10 +01:00
Ken Collins
b193f23390 Use table_exists? in #initialize_schema_migrations_table [#1923 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-05-01 14:24:40 +01:00
Jeremy Kemper
dc9f53b05b Selectively require rake sshpublisher so full gem isn't required 2009-04-30 21:02:23 -07:00
Jeremy Kemper
9b852af497 Explicitly require builder for to_xml 2009-04-30 20:34:11 -07:00
Emilio Tagua
db892ea775 Fix duplicated test name
[#2581 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-04-29 15:46:43 -07:00
Emilio Tagua
4246a79a99 Show executed queries when assert_sql assertion fails [#2573 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-04-28 22:11:47 +01:00
Eloy Duran
da3c21ead5 Ensure the parent record is always saved when the child is invalid. [#2249 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-04-27 19:25:27 +01:00
Jeremy Kemper
6e3e00219b Fix differing rails_to_json arity 2009-04-26 20:26:44 -07:00
Jeremy Kemper
706f313231 Use Array.wrap 2009-04-26 20:24:45 -07:00
Emilio Tagua
a841cd2503 Fix models load order to be able to run unit tests.
[#2550 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-04-23 16:02:11 -07:00
rick
3c4c6bd0df * Add pluggable JSON backends with support for the JSON gem. [rick]
Example: ActiveSupport::JSON.backend = "JSONGem"

  All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode().  Use of #to_json is not recommended, as it may clash with other libraries that overwrite it.  However, you can recover Rails specific functionality
  if you really want to use #to_json.

    gem 'json'
    ActiveSupport::JSON.backend = "JSONGem"

    class ActiveRecord::Base
      alias to_json rails_to_json
    end
2009-04-23 00:08:40 -07:00
Jeremy Kemper
7f6779c1d5 Merge branch 'master' into cherry
Conflicts:
	activesupport/lib/active_support.rb
2009-04-22 16:53:58 -07:00
Jeremy Kemper
6fee981fa4 Opt in to JSON 2009-04-22 16:48:58 -07:00
Jeremy Kemper
f5d720fb96 Opt in to Dependencies 2009-04-22 16:42:14 -07:00
Jeremy Kemper
ab321268f8 No more free lunch 2009-04-22 16:10:49 -07:00
Alex Pooley
504d16ccdf Add microsecond support for sqlite adapter [#1982 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-04-21 18:05:07 +01:00
Pratik Naik
2e6d1bf43e Change table to prevent copying indexes on sqlite2 2009-04-21 13:28:49 +01:00
Pratik Naik
2381f6f3dc Specify :group with the table name for it to work on sqlite3 2009-04-21 13:11:56 +01:00
Pratik Naik
6513dde490 Fix tests for sqlite3 3.6.xx 2009-04-21 13:06:26 +01:00
Max Lapshin
f3ac4f387d Fixed dumping from postgresql columns in index in wrong order. [#2515 state:resolved]
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
2009-04-21 11:44:13 +01:00
Scott Woods
64b33b6cf9 Quote table names when casting to regclass so that capitalized tables are supported. [#2418 state:resolved]
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
2009-04-21 11:43:38 +01:00
Max Lapshin
cdcd638c2f Fixed wrong quoting of index names in postgres [#2402 state:resolved]
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
2009-04-21 11:42:40 +01:00
Pratik Naik
de0ea38663 Ensure :dependent => :delete_all works for association with hash conditions 2009-04-20 18:12:40 +01:00
Pratik Naik
489abfd3b2 Ensure JoinAssociation uses aliased table name when multiple associations have hash conditions on the same table 2009-04-20 13:51:11 +01:00
David Heinemeier Hansson
abb899c54e Added :touch option to belongs_to associations that will touch the parent record when the current record is saved or destroyed [DHH] 2009-04-16 17:25:55 -05:00
David Heinemeier Hansson
fdb61f02c5 Added ActiveRecord::Base#touch to update the updated_at/on attributes with the current time [DHH] 2009-04-16 16:48:37 -05:00
Carl Lerche & Yehuda Katz
906aebceed Bring abstract_controller up to date with rails/master
Resolved all the conflicts since 2.3.0 -> HEAD. Following is a list
of commits that could not be applied cleanly or are obviated with the
abstract_controller refactor. They all need to be revisited to ensure
that fixes made in 2.3 do not reappear in 3.0:

2259ecf368
AR not available
  * This will be reimplemented with ActionORM or equivalent

06182ea02e
implicitly rendering a js response should not use the default layout
[#1844 state:resolved]
  * This will be handled generically

893e9eb995
Improve view rendering performance in development mode and reinstate
template recompiling in production [#1909 state:resolved]
  * We will need to reimplement rails-dev-boost on top of the refactor;
    the changes here are very implementation specific and cannot be
    cleanly applied. The following commits are implicated:

      199e750d46
      3942cb406e
      f8ea9f85d4
      e3b166aab3
      ae9f258e03
      44423126c6

0cb020b4d6
workaround for picking layouts based on wrong view_paths
[#1974 state:resolved]
  * The specifics of this commit no longer apply. Since it is a two-line
    commit, we will reimplement this change.

8c5cc66a83
make action_controller/layouts pick templates from the current instance's
view_paths instead of the class view_paths [#1974 state:resolved]
  * This does not apply at all. It should be trivial to apply the feature
    to the reimplemented ActionController::Base.

87e8b16246
fix HTML fallback for explicit templates [#2052 state:resolved]
  * There were a number of patches related to this that simply compounded
    each other. Basically none of them apply cleanly, and the underlying
    issue needs to be revisited. After discussing the underlying problem
    with Koz, we will defer these fixes for further discussion.
2009-04-13 15:18:45 -07:00
Max Lapshin
70de8e64e3 Support multiple schemas in table names for postgresql [#390 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-04-05 12:36:36 +01:00
Pratik Naik
632bbbfe1c Merge docrails 2009-04-05 12:36:36 +01:00
Luca Guidi
42cdc7571d Ensure SqlBypass use ActiveRecord::Base connection
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#https://rails.lighthouseapp.com/attachments/106066/0001-Ensure-SqlBypass-use-ActiveRecord-Base-connection.patch state:committed]
2009-04-05 21:00:50 +12:00
Pratik Naik
f97832b1e4 Merge docrails 2009-03-24 12:15:43 +00:00
Pratik Naik
18eb80ccc7 Merge docrails 2009-03-16 11:28:36 +00:00
David Heinemeier Hansson
73fc42cc0b Prepare for final 2.3 release 2009-03-15 22:06:50 -05:00
Jason King
ac3848201d SQLite adapters now support DDL transactions [#2080 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-14 12:58:42 +00:00
Chris Kampmeier
3c64c9a575 Fix spelling of an internal method [#1734 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-12 15:41:31 +00:00
Luca Guidi
47bdf3bf40 Ensure AutosaveAssociation runs remove callbacks [#2146 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-12 15:24:37 +00:00
Elijah Miller
91b98cf0a5 Returning nil from named scope lambda is equivalent to an empty hash [#1773 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-12 15:06:19 +00:00
Murray Steele
db26ace030 Ensure NoMethodError isn't raised when some of the nested eager loaded associations are empty [#1696 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-03-12 13:49:16 +00:00