Admin::FaqsController:Class 的未定义方法`t' [英] undefined method `t' for Admin::FaqsController:Class
本文介绍了Admin::FaqsController:Class 的未定义方法`t'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目中,我在命名空间 admin 中有控制器,我正在使用面包屑_on_rails 来构建面包屑.我的控制器看起来像:模块管理员
in my project i have controller in namespace admin and I'm using breadcrumbs_on_rails to build breadcrums. My controller looks like: module Admin
class FaqsController < Admin::ApplicationController
include FaqsHelper
load_and_authorize_resource
add_breadcrumb t('faqs.faqs_list') , :faqs_path #this line makes the problem
def index
@faqs = @faqs
add_breadcrumb t('faqs.faqs_list')
end
def new
add_breadcrumb t('faqs.new')
end
#other code ommitted
end
end
我可以在 new、edit 和其他控制器操作中使用 t 方法,但是当这个t"不在控制器操作中时,我会出现以下错误:
i can use t method in new, edit and other controller action but when this 't' is not in the controller action i have the follwoing error:
undefined method `t' for Admin::FaqsController:Class
有什么想法吗?
推荐答案
使用 I18n.t
而不是 t
.
这篇关于Admin::FaqsController:Class 的未定义方法`t'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文