ruby on rails - How to invoke flash messages defined in locales -
i have message called my_message
in config/locales/post.en.yml
follow:
en: post: show: my_message: "post saved. , boom!"
how call :my_message flash in controller's method?
class postscontroller < applicationcontroller def show flash[:error] = my_message end end
in application controller rails 4 send locale in parameters in contoller params[:locale]
before_action :set_locale def set_locale i18n.locale = params[:locale] || i18n.default_locale end
then
flash[:error] = t('post.show.my_message')
Comments
Post a Comment