From 105f9b8154bbee88b45e0bb9de949206cbc1ba02 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 28 Mar 2010 13:26:13 +0200 Subject: adds missing requires for Object#duplicable? --- activerecord/lib/active_record/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 367b4ce217..02db241ee0 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -13,6 +13,7 @@ require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/string/behavior' require 'active_support/core_ext/object/singleton_class' require 'active_support/core_ext/module/delegation' +require 'active_support/core_ext/object/duplicable' require 'arel' require 'active_record/errors' -- cgit v1.2.3 From 76f024ac8db82490a99c71d0d8951d677e3bc9bc Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sun, 28 Mar 2010 14:15:02 +0200 Subject: adds missing requires for Object#blank? and Object#present? --- activerecord/lib/active_record/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 02db241ee0..b81434c1f7 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -14,6 +14,7 @@ require 'active_support/core_ext/string/behavior' require 'active_support/core_ext/object/singleton_class' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/object/duplicable' +require 'active_support/core_ext/object/blank' require 'arel' require 'active_record/errors' -- cgit v1.2.3 From a4eab8f1f3306656bef3bacebaceec4e88fdc57b Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 28 Mar 2010 19:11:06 -0700 Subject: Update example of default_scope to use the new arel finder syntax --- activerecord/lib/active_record/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index b81434c1f7..21b89694fc 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1290,7 +1290,7 @@ module ActiveRecord #:nodoc: # options argument is the same as in find. # # class Person < ActiveRecord::Base - # default_scope :order => 'last_name, first_name' + # default_scope order('last_name, first_name') # end def default_scope(options = {}) self.default_scoping << construct_finder_arel(options) -- cgit v1.2.3 From 67d1cec4c8a65846cc3b2779bc5eca7b8b73e6fc Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 22 Feb 2010 10:46:45 +0000 Subject: Add the ability to specify table_name_prefix on individual modules Signed-off-by: wycats --- activerecord/lib/active_record/base.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 21b89694fc..289c95ad8f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -338,6 +338,9 @@ module ActiveRecord #:nodoc: # Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all # table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace # for tables in a shared database. By default, the prefix is the empty string. + # + # If you are organising your models within modules you can add a prefix to the models within a namespace by defining + # a singleton method in the parent module called table_name_prefix which returns your chosen prefix. cattr_accessor :table_name_prefix, :instance_writer => false @@table_name_prefix = "" @@ -765,7 +768,7 @@ module ActiveRecord #:nodoc: contained = contained.singularize if parent.pluralize_table_names contained << '_' end - name = "#{table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" + name = "#{modularized_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" end @quoted_table_name = nil @@ -773,6 +776,10 @@ module ActiveRecord #:nodoc: name end + def modularized_table_name_prefix #:nodoc: + (parents.detect{ |p| p.respond_to?(:table_name_prefix) } || self).table_name_prefix + end + # Defines the column name for use with single table inheritance # -- can be set in subclasses like so: self.inheritance_column = "type_id" def inheritance_column -- cgit v1.2.3 From 5f7bc47303933ec67700f6390c98d889f6d9b0d1 Mon Sep 17 00:00:00 2001 From: wycats Date: Sun, 28 Mar 2010 23:45:38 -0700 Subject: Rename modularized_table_name_prefix to full_table_name_prefix [#4032 state:resolved] --- activerecord/lib/active_record/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 289c95ad8f..4d9493e82f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -768,7 +768,7 @@ module ActiveRecord #:nodoc: contained = contained.singularize if parent.pluralize_table_names contained << '_' end - name = "#{modularized_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" + name = "#{full_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}" end @quoted_table_name = nil @@ -776,7 +776,7 @@ module ActiveRecord #:nodoc: name end - def modularized_table_name_prefix #:nodoc: + def full_table_name_prefix #:nodoc: (parents.detect{ |p| p.respond_to?(:table_name_prefix) } || self).table_name_prefix end -- cgit v1.2.3 From 56bed512f92050f95701eca4f918086a8f1cda1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 30 Mar 2010 01:04:34 +0200 Subject: Fix dom_id for ActiveRecord [#4296 state:resolved] --- activerecord/lib/active_record/base.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 4d9493e82f..80f8569644 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2223,6 +2223,7 @@ module ActiveRecord #:nodoc: extend QueryCache::ClassMethods extend ActiveSupport::Benchmarkable + include ActiveModel::Conversion include Validations include Locking::Optimistic, Locking::Pessimistic include AttributeMethods @@ -2232,12 +2233,10 @@ module ActiveRecord #:nodoc: include AttributeMethods::Dirty include Callbacks, ActiveModel::Observing, Timestamp include Associations, AssociationPreload, NamedScope - include ActiveModel::Conversion # AutosaveAssociation needs to be included before Transactions, because we want # #save_with_autosave_associations to be wrapped inside a transaction. include AutosaveAssociation, NestedAttributes - include Aggregations, Transactions, Reflection, Serialization NilClass.add_whiner(self) if NilClass.respond_to?(:add_whiner) -- cgit v1.2.3 From 4aded43b73ff94dbf06b4a2d2075651ce454e1d5 Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 29 Mar 2010 17:08:08 -0700 Subject: Replace the placeholder base_hook API with on_load. To specify some code that should run during framework load do: ActiveSupport.on_load(:action_controller) do # Code run in the context of AC::Base end --- activerecord/lib/active_record/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/base.rb') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 80f8569644..75576f146a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2245,4 +2245,4 @@ end # TODO: Remove this and make it work with LAZY flag require 'active_record/connection_adapters/abstract_adapter' -ActiveRecord.run_base_hooks(ActiveRecord::Base) +ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base) -- cgit v1.2.3