大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 使用I18n.t提交按钮帮助程序,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
fr: submit: create: user: "Créer mon compte" product: "Déposer l'objet" session: "Se connecter" update: user: "Mettre à jour mon compte" product: "Modifier l'objet"
我试过这个:
def submiT_Button(model) if model == nil I18n.t('submit.create.%{model}') else I18n.t('submit.update.%{model}') end end
但它没有用,rspec发给我的是:
Capybara::ElementNotFound: Unable to find button ...
我知道这是一个语法问题,但我找不到如何使这项工作……
fr: Helpers: submit: # This will be the default ones,will take effect if no other # are specifically defined for the models. create: "Créer %{model}" update: "Modifier %{model}" # Those will however take effect for all the other models below # for which we define a specific label. user: create: "Créer mon compte" update: "Mettre à jour mon compte" product: create: "Déposer l'objet" update: "Modifier l'objet" session: create: "Se connecter"
之后,您只需要像这样定义提交按钮:
<%= f.submit class: 'any class you want to apply' %>
Rails将获取按钮所需的标签.
你可以看到更多关于它的信息here
以上是大佬教程为你收集整理的ruby-on-rails – 使用I18n.t提交按钮帮助程序全部内容,希望文章能够帮你解决ruby-on-rails – 使用I18n.t提交按钮帮助程序所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。