diff options
-rw-r--r-- | actionpack/lib/abstract_controller/translation.rb | 8 | ||||
-rw-r--r-- | actionpack/test/abstract/translation_test.rb | 13 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 7 |
3 files changed, 27 insertions, 1 deletions
diff --git a/actionpack/lib/abstract_controller/translation.rb b/actionpack/lib/abstract_controller/translation.rb index 6d68cf4944..b6c484d188 100644 --- a/actionpack/lib/abstract_controller/translation.rb +++ b/actionpack/lib/abstract_controller/translation.rb @@ -1,6 +1,12 @@ module AbstractController module Translation def translate(*args) + key = args.first + if key.is_a?(String) && (key[0] == '.') + key = "#{ controller_path.gsub('/', '.') }.#{ action_name }#{ key }" + args[0] = key + end + I18n.translate(*args) end alias :t :translate @@ -10,4 +16,4 @@ module AbstractController end alias :l :localize end -end
\ No newline at end of file +end diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb index 0194ee943f..99064a8b87 100644 --- a/actionpack/test/abstract/translation_test.rb +++ b/actionpack/test/abstract/translation_test.rb @@ -23,4 +23,17 @@ class TranslationControllerTest < ActiveSupport::TestCase def test_action_controller_base_responds_to_l assert_respond_to @controller, :l end + + def test_lazy_lookup + expected = 'bar' + @controller.stubs(:action_name => :index) + I18n.stubs(:translate).with('action_controller.base.index.foo').returns(expected) + assert_equal expected, @controller.t('.foo') + end + + def test_default_translation + key, expected = 'one.two' 'bar' + I18n.stubs(:translate).with(key).returns(expected) + assert_equal expected, @controller.t(key) + end end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 36d94fb38b..4a44fd33fd 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,12 @@ ## Rails 4.0.0 (unreleased) ## +* The migration generator now creates a join table with (commented) indexes every time + the migration name contains the word `join_table`: + + rails g migration create_join_table_for_artists_and_musics artists:index musics + + *Aleksey Magusev* + * Add `add_reference` and `remove_reference` schema statements. Aliases, `add_belongs_to` and `remove_belongs_to` are acceptable. References are reversible. Examples: |