Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method `t' for Admin::FaqsController:Class

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

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

Any ideas?

like image 857
Mateusz Urbański Avatar asked Feb 19 '14 11:02

Mateusz Urbański


2 Answers

Use I18n.t instead of just t.

like image 141
Andrea Salicetti Avatar answered Oct 04 '22 14:10

Andrea Salicetti


I can suggest to extend your class with extend ActionView::Helpers::TranslationHelper It will allow you to use #t and #l helpers.

like image 38
Skydan Avatar answered Oct 04 '22 14:10

Skydan