From 1c44d54b51fbbbc35e44c410bbabcaa4b6c90998 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Sun, 2 Jun 2013 22:18:52 +0100 Subject: [PATCH] Move flash messages to locale. --- app/controllers/contacts_controller.rb | 4 ++-- config/locales/en.yml | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index 32e32e1..ba724c7 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -7,9 +7,9 @@ class ContactsController < ApplicationController def create @contact = Contact.new(params[:contact]) if @contact.save - redirect_to(:new_contact, :notice => "Thanks for your email, I'll be in touch as soon as possible.") + redirect_to(:new_contact, :notice => t("contact.thanks")) else - flash[:alert] = "Please fill in fields marked in red." + flash[:alert] = t("contact.invalid") render :new end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 179c14c..d7057ce 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,4 +2,6 @@ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: - hello: "Hello world" + contact: + thanks: Thanks for your email, I'll be in touch as soon as possible. + invalid: Please fill in fields marked in red.