Are Rails 2.3.4 and the jquery form plugin working on development, not production?

I am trying to create a contact form in Rails 2.3.4. I am using the jQuery Form plugin along with this ( http://bassistance.de/jquery-plugins/jquery-plugin-validation/ ) for validation. Everything works in my development environment (mac os x snow leopard), the loading gif appears, and an email is sent in my log and a "request completed" notification appears. But on my production machine, the gif loading just continues and the form is not submitted. I waited as long as I could, nothing.

Here is my code:

/public/javascripts/application.js


 // client-side validation and ajax submit contact form 
 $('#contactForm').validate( {
  rules: {
   'email[name]': { required: true },
   'email[address]': {
    required: true,
    email: true
   },
   'email[subject]': {
    required: true
   },
   'email[body]': {
    required: true
   }
  },
  messages: {
   'email[name]': "Please enter your name.",
   'email[address]': "Please enter a valid email address.",
   'email[subject]': "Please enter a subject.",
   'email[body]': "Please enter a message."
  },
  submitHandler: function(form) {
   $(form).ajaxSubmit({
    dataType: 'script',
    beforeSend: function() {
     $(".loadMsg").show();
    }
   });
   return false;
  }  
 });

      

I am using submitHandler to submit the actual ajaxSubmit. I added "dataType:" script "and" beforeSubmit "to load the graph.


  def send_mail
    if request.post?
      respond_to do |wants|
        ContactMailer.deliver_contact_request(params[:email])
        flash[:notice] = "Email was successfully sent."
        wants.js
      end
    end
  end

      

Everything works fine, but not in production. What am I missing or something amiss?

+2


source to share


1 answer


I would check the production logs to see if the Mailer can send an email. A couple of things I would check:

  • Have you specified the mailer config only in your /development.rb environments, not in /production.rb environments or environment.rb?
  • Since showing your "loader" it is unlikely that it will not send the correct JS files, but I would check to make sure it sends the correct versions, perhaps you are caching your JS files.

You can also run script / server local work locally, or switch to Passenger LAN for production to test it, if test it to test on your real servers.



I'll also grab Mailer and pull it out of the responses_to block:

  def send_mail
    if request.post?
      ContactMailer.deliver_contact_request(params[:email])
      respond_to do |wants|
        wants.js
      end
    end
  end

      

+1


source







All Articles