Skip to content

Commit

Permalink
Merge pull request globalizejs#202 from ybart/issue-202-column_for_at…
Browse files Browse the repository at this point in the history
…tribute_delegation

Formtastic inputs for translated attributes don't get type information
  • Loading branch information
parndt committed Feb 22, 2013
2 parents 9a4895b + b05a906 commit 06c87a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/globalize/active_record/instance_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ def rollback
translation_caches[::Globalize.locale] = translation.previous_version
end

def column_for_attribute name
translated_attribute_names.include?(name) ? globalize.send(:column_for_attribute, name) : super
end

private

def update(*)
Expand Down
5 changes: 5 additions & 0 deletions test/globalize3/attributes_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,9 @@ class AttributesTest < Test::Unit::TestCase
assert_equal '', account.business_name
assert_equal '', account.notes
end

test 'delegates column_for_attribute to translations adapter' do
post = Post.new
assert_equal post.globalize.send(:column_for_attribute, :title), post.column_for_attribute(:title)
end
end

0 comments on commit 06c87a8

Please sign in to comment.