Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6088175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:57:18+00:00 2026-05-23T11:57:18+00:00

I have a form that sends out a notification when a client fills out

  • 0

I have a form that sends out a notification when a client fills out the form. I know would like to be able to save this information in my database table but am having an issue. It doesn’t save a copy to the database at all unless I clear out my model. here’s what the controller and model look like.

class ContactController < ApplicationController

  def index
    @contact = Contact.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @contact }
    end
  end

  def create
    @contact = Contact.new(params[:contact])

    if verify_recaptcha(request.remote_ip, params)[:status] == 'false'
      render 'index', :layout => '/layouts/application.html.erb'
  elsif
    respond_to do |format|
      if @contact.save
        format.html { redirect_to("/contact", :notice => 'Your Message was successfully sent.') }
      else
        format.html { render :action => "index" }
        format.xml  { render :xml => @contact.errors, :status => :unprocessable_entity }
      end
    end
  end
end

end

model

class Contact < ActiveRecord::Base

  include ActiveModel::Validations

  validates_presence_of :email, :phone, :phone_type, :address, :fullName, :content, :userBrowser, :userOS

  attr_accessor :id, :email, :phone, :phone_type, :address, :fullName, :content, :userBrowser, :userOS

  def initialize(attributes = {})
    attributes.each do |key, value|
      self.send("#{key}=", value)
    end
    @attributes = attributes
  end

  def read_attribute_for_validation(key)
    @attributes[key]
  end

  def to_key
  end

  def save
    if self.valid?
      Notifier.contact_notification(self).deliver
      return true
    end
    return false
  end
end

all help is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T11:57:18+00:00Added an answer on May 23, 2026 at 11:57 am

    I’m not sure why your overriding so much of the parent methods, all you should need to make the notifier work is

    class Contact < ActiveRecord::Base
      validates_presence_of :email, :phone, :phone_type, :address, :fullName, :content, :userBrowser, :userOS
    
      after_save :send_contact_notification
    
      def send_contact_notification
        Notifier.contact_notification(self).deliver
      end
    end
    

    Also you shouldn’t have to include the Validations, they’re available already, and if your trying to protect the model fields, you probably want attr_accessible not attr_accessor, since the later is taken care of by ActiveRecord already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
I have a form that I would like to style. specifcally I would like
I have a simple web form that sends and email out via .NET C#.
I have a form that sends info into a database table. I have it
I have the following JQuery AJAX call that sends HTML form data to my
I'm building an application that's self-hosted, and I'd like to have some form of
I have an incoming soap message wich form is TStream (Delphi7), server that send
I have form that displays several keywords (standard set of choice lists that changes
I currently have form that checks if a user has unsubmitted changes when they
I have a form that contains a GridView control which is databound to an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.