Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hukl committed Jan 11, 2010
1 parent 65c83aa commit 7672e7e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/globalize/active_record.rb
Expand Up @@ -107,7 +107,7 @@ def required_attributes
end.map(&:name) end.map(&:name)
end end


def respond_to?(method) def respond_to?(method, *args)
method.to_s =~ /^find_by_(\w+)$/ && translated_attribute_names.include?($1.to_sym) || super method.to_s =~ /^find_by_(\w+)$/ && translated_attribute_names.include?($1.to_sym) || super
end end


Expand Down
5 changes: 5 additions & 0 deletions test/active_record_test.rb
Expand Up @@ -428,6 +428,11 @@ class Baz < ActiveRecord::Base
test "don't override existing translation class" do test "don't override existing translation class" do
assert PostTranslation.new.respond_to?(:existing_method) assert PostTranslation.new.respond_to?(:existing_method)
end end

test "has_many and named scopes work with globalize" do
blog = Blog.create
assert_nothing_raised { blog.posts.foobar }
end
end end


# TODO error checking for fields that exist in main table, don't exist in # TODO error checking for fields that exist in main table, don't exist in
Expand Down
9 changes: 5 additions & 4 deletions test/data/models.rb
@@ -1,7 +1,7 @@
require 'ruby2ruby' #require 'ruby2ruby'
require 'parse_tree' #require 'parse_tree'
require 'parse_tree_extensions' #require 'parse_tree_extensions'
require 'pp' #require 'pp'


class PostTranslation < ActiveRecord::Base class PostTranslation < ActiveRecord::Base
def existing_method ; end def existing_method ; end
Expand All @@ -10,6 +10,7 @@ def existing_method ; end
class Post < ActiveRecord::Base class Post < ActiveRecord::Base
translates :subject, :content translates :subject, :content
validates_presence_of :subject validates_presence_of :subject
named_scope :foobar, :conditions => { :title => "foobar" }
end end


class Blog < ActiveRecord::Base class Blog < ActiveRecord::Base
Expand Down

0 comments on commit 7672e7e

Please sign in to comment.