Sha256: ebe4f6693aca4f9219b12c998a50fb1f6beac4dec40469143989115fdbe3fc43

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

class FeedbackController < UmlautController
  def new
    contact_email_lookup(params[:contact_id])
    # default render
  end

  def create    
    contact_config = contact_email_lookup(params[:contact_id])
    to_address = contact_config[:email_address]

    options = params.slice(:name, :email, :feedback)
    if params[:request_id] && umlaut_request = Request.find_by_id(params[:request_id])
      options = options.merge(
        :umlaut_request => umlaut_request
      )
    end

    action_mailer_deliver FeedbackMailer.feedback(request.host_with_port, to_address, options)

    flash[:alert_success] = "Thanks, your message has been sent."

    if umlaut_request
      redirect_to :controller => "resolve", :action => :index, "umlaut.request_id" => umlaut_request.id
    else
      redirect_to root_url
    end
  end

  protected
  def contact_email_lookup(contact_id)
    unless contact_id
      raise NoFeedbackEmailFoundException.new("Missing a contact_id, needed to look up feedback destination email.")
    end
    contact_config = umlaut_config.feedback && umlaut_config.feedback.contacts && umlaut_config.feedback.contacts[contact_id]

    unless contact_config && contact_config[:email_address]
      raise NoFeedbackEmailFoundException.new("Could not find feedback destination email for contact_id: `#{contact_id}`")
    end

    return contact_config
  end

  class NoFeedbackEmailFoundException < ArgumentError
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
umlaut-4.1.7 app/controllers/feedback_controller.rb
umlaut-4.1.6 app/controllers/feedback_controller.rb
umlaut-4.1.5 app/controllers/feedback_controller.rb
umlaut-4.1.4 app/controllers/feedback_controller.rb
umlaut-4.1.3 app/controllers/feedback_controller.rb
umlaut-4.1.2 app/controllers/feedback_controller.rb
umlaut-4.1.1 app/controllers/feedback_controller.rb
umlaut-4.1.0 app/controllers/feedback_controller.rb
umlaut-4.1.0.pre3 app/controllers/feedback_controller.rb
umlaut-4.1.0.pre.2 app/controllers/feedback_controller.rb
umlaut-4.1.0.pre.alpha.1 app/controllers/feedback_controller.rb