Class: NewslettersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/newsletters_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#get_login_link, #set_locale_with_config

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/newsletters_controller.rb', line 4

def create
  newsletter = Newsletter.new(params[:newsletter])
  newsletter.email = newsletter.email.to_s.strip
  if newsletter.save
    flash[:notice] = t(:success, :scope => [:newsletter, :create])
    @page = Page.find_by_single_key('inscription_reussie')
  else
    if error = newsletter.errors.on(:email)
      flash[:error] = t(:invalid_email, :scope => [:newsletter, :create], :error => error.last)
    else
      flash[:error] = newsletter.errors.full_messages.first
    end
  end
  return redirect_to :back
end