我想为提交按钮编写一个助手,它考虑到获得正确翻译的操作(创建或更新)。他们来了 :
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 ...
我知道这是一个语法问题,但我不知道如何使这项工作......