私はモデルを飾るためにドレイパーの宝石を使用します。ここで私はかなり古典的な設定を持っています:Draper gemでi18n translateメソッドを使用するには?
# app/decorators/subject_decorator.rb
class SubjectDecorator < ApplicationDecorator
decorates :subject
def edit_link
h.link_to(h.t('.edit'), '#')
end
end
私は国際化にi18nを使用します。しかし、これを実行すると、私は得る:
Cannot use t(".edit") shortcut because path is not available
私は誰もこれを前に行っているのだろうかと思いましたか?それはかなりまっすぐ進むはずです。あなたが使用する必要があり、あなたのコード内
'model_name.i18n_key + key'を使う方が良いかもしれません。 –