Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'upstream/master'

  • Loading branch information...
commit 86fe209ec3970dab50b4f5c8cb17d156b8ed3c57 2 parents 4edd6f9 + ffd2739
@moskyt authored
View
2  lib/globalize/active_record.rb
@@ -120,7 +120,7 @@ def required_attributes
end.map(&:name)
end
- def respond_to?(method)
+ def respond_to?(method, *args, &block)
method.to_s =~ /^find_by_(\w+)$/ && translated_attribute_names.include?($1.to_sym) || super
end
View
5 test/active_record_test.rb
@@ -428,6 +428,11 @@ class Baz < ActiveRecord::Base
test "don't override existing translation class" do
assert PostTranslation.new.respond_to?(:existing_method)
end
+
+ test "has_many and named scopes work with globalize" do
+ blog = Blog.create
+ assert_nothing_raised { blog.posts.foobar }
+ end
end
# TODO error checking for fields that exist in main table, don't exist in
View
9 test/data/models.rb
@@ -1,7 +1,7 @@
-require 'ruby2ruby'
-require 'parse_tree'
-require 'parse_tree_extensions'
-require 'pp'
+#require 'ruby2ruby'
+#require 'parse_tree'
+#require 'parse_tree_extensions'
+#require 'pp'
class PostTranslation < ActiveRecord::Base
def existing_method ; end
@@ -10,6 +10,7 @@ def existing_method ; end
class Post < ActiveRecord::Base
translates :subject, :content
validates_presence_of :subject
+ named_scope :foobar, :conditions => { :title => "foobar" }
end
class Blog < ActiveRecord::Base
Please sign in to comment.
Something went wrong with that request. Please try again.