How to use the HAML t() helper in RoR

本秂侑毒 提交于 2019-12-11 12:23:16

问题


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:


hope in translational file you have en.yml

en:
  article: MyArticle

Then

%h2= t 'article'

if you want dynamically ``

%h2= t '#{model_name}'


来源:https://stackoverflow.com/questions/33873894/how-to-use-the-haml-t-helper-in-ror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!