Sha256: 9dbad12d6d3286bbecec28c0a0668c88fea0caaee7764b761626edd58b904654

Contents?: true

Size: 967 Bytes

Versions: 5

Compression:

Stored size: 967 Bytes

Contents

# -*- encoding : utf-8 -*-
class FeedbackController < ApplicationController

  # http://expressica.com/simple_captcha/
  # include SimpleCaptcha::ControllerHelpers

  # show the feedback form
  def show
    @nav_li_active = 'contact'
    @errors=[]
    if request.post?
      if validate
        Notifier.feedback(params).deliver_now
        redirect_to feedback_complete_path
      end
    end
  end

  protected

  # validates the incoming params
  # returns either an empty array or an array with error messages
  def validate
    unless params[:name] =~ /\w+/
      @errors << t('blacklight.feedback.valid_name')
    end
    unless params[:email] =~ /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
      @errors << t('blacklight.feedback.valid_email')
    end
    unless params[:message] =~ /\w+/
      @errors << t('blacklight.feedback.need_message')
    end
    #unless simple_captcha_valid?
    #  @errors << 'Captcha did not match'
    #end
    @errors.empty?
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
commonwealth-vlr-engine-0.0.7 app/controllers/feedback_controller.rb
commonwealth-vlr-engine-0.0.4 app/controllers/feedback_controller.rb
commonwealth-vlr-engine-0.0.3 app/controllers/feedback_controller.rb
commonwealth-vlr-engine-0.0.2 app/controllers/feedback_controller.rb
commonwealth-vlr-engine-0.0.1 app/controllers/feedback_controller.rb