Skip to content
Browse files

Merge pull request #6606 from amatsuda/ar_relation_model_method

AR::Relation#model would be a better API than AR::Relation#klass
  • Loading branch information...
2 parents 8c6fcbc + 566c8d5 commit d168c1f7a779c6b0322a747b7accf035fe7b3db3 @rafaelfranca rafaelfranca committed Aug 21, 2012
Showing with 6 additions and 0 deletions.
  1. +1 −0 activerecord/lib/active_record/relation.rb
  2. +5 −0 activerecord/test/cases/relation_test.rb
View
1 activerecord/lib/active_record/relation.rb
@@ -18,6 +18,7 @@ class Relation
attr_reader :table, :klass, :loaded
attr_accessor :default_scoped
+ alias :model :klass
alias :loaded? :loaded
alias :default_scoped? :default_scoped
View
5 activerecord/test/cases/relation_test.rb
@@ -19,6 +19,11 @@ def test_construction
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|

0 comments on commit d168c1f

Please sign in to comment.
Something went wrong with that request. Please try again.