ruby-on-rails-3 - rails twitter bootstrap helper 方法

标签 ruby-on-rails-3 helper twitter-bootstrap-rails

我正在使用 twitter-bootstrap-rails我的应用程序中的 gem 。它似乎带有一系列辅助方法,可以在主题 View 中创建例如编辑和删除按钮:

<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
                  cohort_path(cohort),
                  :method => :delete,
                  :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
                  :class => 'btn btn-mini btn-danger' %>

这些 t() 方法和助手在哪里定义的?我怎样才能改变它们?例如,如果我想将销毁按钮上的标签更改为“删除”,我可以将上述内容更改为:
<%= link_to t('.destroy', :default => "Delete"),
                  cohort_path(cohort),
                  :method => :delete,
                  :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
                  :class => 'btn btn-mini btn-danger' %>

我真正想做的是改变t("helpers.links.destroy")在我的所有 View 中显示“删除”而不是“销毁”。我可以这样做吗?感谢你的帮助!

最佳答案

您所要做的就是将以下内容添加到您的 i18n Rails 文件中(在路径“config/locales/en.yml”中):

<pre>
en:
 helpers:
    links:
      back: "Back Page"
      destroy: "Delete"
</pre>

方法 t() 用于 i18n 一个 Rails 应用程序。

关于ruby-on-rails-3 - rails twitter bootstrap helper 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11224276/

相关文章:

ruby-on-rails - 堆栈级别太深且 before_save

ruby-on-rails - 在 before_action 中访问 application_helper

ruby-on-rails - 在 Rails 中设置动态数据目标和 id

ruby-on-rails-3 - 如何在 Rails 3 中进行枚举?

ruby-on-rails - Rails 3 教程 10.4.2 : NoMethodError undefined method `admin?' for nil:NilClass

delphi - Delphi Win32 中的类帮助器和字符串

ruby-on-rails - 为什么我的 helper 递归方法不返回每个值?

jquery - Rails dataTable Bootstrap 样式不起作用

css - 使用 breadcrumbs_on_rails gem 时,为什么我的面包屑在本地的样式与在 heroku 上的样式不同?

ruby-on-rails - 访问 URL 参数 Project.find(params[ :project_id]) in the application_helper. rb