Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0
Last active August 29, 2015 14:04
Show Gist options
  • Save MikeRogers0/99e9e476be81a2b554be to your computer and use it in GitHub Desktop.
Save MikeRogers0/99e9e476be81a2b554be to your computer and use it in GitHub Desktop.
An example of a terrible approach to a contact form.
class ContactUsController < ApplicationController
def index
end
def send_enquiry
if contact_form_valid?
ContactUsMailer.send_enquiry(contact_form_params).deliver
return redirect_to action: :thank_you
end
render :index
end
def thank_you
end
private
def contact_form_valid?
contact_form_params[:name].present? && contact_form_params[:email].present? && contact_form_params[:email].present?
end
def contact_form_params
params.require(:contact_form).permit!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment