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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -