Sha256: cfe4d4de3e3527ffdd047b10126d302b84b154af5e0baee2ad28f5caf2d29269
Contents?: true
Size: 1.39 KB
Versions: 10
Compression:
Stored size: 1.39 KB
Contents
module Noodall class FormResponsesController < ApplicationController # POST /responses # POST /responses.xml def create # long way of adding a new response to a form (create then append to form model) # as redirecting back to the form will cause errors with half built appended objects @form = Noodall::Form.find(params[:form_id]) @form_response = @form.responses.build(params[:form_response]) @form_response.ip = request.remote_ip @form_response.referrer = request.referer if @form_response.referrer.blank? @form_response.created_at = Time.zone.now respond_to do |format| if @form_response.valid? and @form_response.save unless @form_response.is_spam? begin # mail the response to the form recipient FormMailer.form_response(@form, @form_response).deliver unless @form.email.blank? FormMailer.form_response_thankyou(@form, @form_response).deliver rescue Net::SMTPSyntaxError end end flash[:notice] = 'Thank you for getting in contact.' format.html format.xml { render :xml => @form, :status => :created, :location => @form } else format.html { render 'new' } format.xml { render :xml => @form_response.errors, :status => :unprocessable_entity } end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems