How to use the HAML t() helper in RoR

2019-08-13 15:01发布

I'm developing an application with Rails 4 and I want to use the helper t() with HAML, but I can not

Example usage:

=model_name = @article.class.model_name.human
%h1 Create  t(:model_name)

My first line shows me the correct article, but when I use t() it shows me t(:model_name). Thanks.

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-13 15:32

hope in translational file you have en.yml

en:
  article: MyArticle

Then

%h2= t 'article'

if you want dynamically ``

%h2= t '#{model_name}'
查看更多
登录 后发表回答