I am using locale file to save the English text, and I am using these text in controller by calling it like t(:user_created_message)
.
But when I moved my logic to a class file under /lib/classes/users/user.rb
and tried to access the translate, it shows error like undefined method t for Users::User
How should I load the translate variable when calling from custom classes?
I18n.t :user_created_message
Please read the documentation here, the method you're using only works inside the views.