aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-21 14:43:19 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-08-21 14:43:19 -0700
commitd168c1f7a779c6b0322a747b7accf035fe7b3db3 (patch)
treeb91e9b11ca32fb40336aa93f1e95cd3eac028bed
parent8c6fcbc2b112f09f86c5fd6c262dd8e6e7d4fd4a (diff)
parent566c8d5443a7f1077b33a1a3fc9234f4ecf7bdf3 (diff)
downloadrails-d168c1f7a779c6b0322a747b7accf035fe7b3db3.tar.gz
rails-d168c1f7a779c6b0322a747b7accf035fe7b3db3.tar.bz2
rails-d168c1f7a779c6b0322a747b7accf035fe7b3db3.zip
Merge pull request #6606 from amatsuda/ar_relation_model_method
AR::Relation#model would be a better API than AR::Relation#klass
-rw-r--r--activerecord/lib/active_record/relation.rb1
-rw-r--r--activerecord/test/cases/relation_test.rb5
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 1abbc58314..2d0457636e 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -18,6 +18,7 @@ module ActiveRecord
attr_reader :table, :klass, :loaded
attr_accessor :default_scoped
+ alias :model :klass
alias :loaded? :loaded
alias :default_scoped? :default_scoped
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb
index 5fb54b1ca1..6399111be6 100644
--- a/activerecord/test/cases/relation_test.rb
+++ b/activerecord/test/cases/relation_test.rb
@@ -19,6 +19,11 @@ module ActiveRecord
assert !relation.loaded, 'relation is not loaded'
end
+ def test_responds_to_model_and_returns_klass
+ relation = Relation.new :a, :b
+ assert_equal :a, relation.model
+ end
+
def test_initialize_single_values
relation = Relation.new :a, :b
(Relation::SINGLE_VALUE_METHODS - [:create_with]).each do |method|