title: Ajax + Rails not working on Heroku
body: <p>I have a pop-up sign-in form that has the error messages display in the body of the form via jQuery Ajax.  It works fine on my local environment (PostGresQL, WEBbrick) but not on Heroku.  On Heroku, the user is redirected to a new page which displays just the error message i.e., {"error":"Invalid Email Address: testing@test.com"}</p>
  
  <p>There are actually two signup forms on the page, one that pops up via jQuery Dialog, and the other is embedded on the page.  Thanks for any help.</p>
  
  <p>Here's the controller:
       class MailingListController &lt; ApplicationController</p>
  
  <pre><code> respond_to :json
  
   def create
     gb = Gibbon.new(Settings.mailchimp.api_key)
     res = gb.list_subscribe({:id =&gt; Settings.mailchimp.list_id, :email_address =&gt; params[:email]})
     if res == true
       render(:json =&gt; {:body =&gt; "okay"})
     else
       render(:json =&gt; {:error =&gt; res["error"]})
     end
   rescue
     render(:json =&gt; {:error =&gt; "Fatal Error"})
    end
  end
  </code></pre>
  
  <p>Here's the js (I know, duplicate code, I'm just trying to get it to work):</p>
  
  <pre><code>  // Mailing List Watcher
   var mailingList2 = $("#mailing-list2");
   if ( mailingList2.length ) {
     mailingList2
       .live("completed", function(e){
       })
       .live("success", function(e){
         var that = this;
         $.cookie("mailingListSubmitted", "true", {expires: 7});
         if(mailingList2.find("#mailing-list2 #status2").length == 0){
           mailingList2
             .find("form input[type='text']")
             .after($("&lt;div&gt;&lt;/div&gt;").attr({id : "status2"}))
         }
         mailingList2
           .find("form input[type='text']")
             .attr("disabled", true)
             .fadeOut(5000);
         $("#mailing-list2 #status2")
           .text("Email submitted successfully!")
           .effect("highlight", { }, 1000);
       })
       .live("failure", function(e, error){
        if(mailingList2.find("#mailing-list2 #status2").length == 0){
           mailingList2
             .find("form input[type='text']")
             .after($("&lt;div&gt;&lt;/div&gt;").attr({id : "status2"}))
         }
         $("#mailing-list2 #status2")
           .text(error)
           .effect("highlight", {}, 1000);
       })
       .live("submittal", function(e, emailAddress){
         if ( emailAddress == "" || emailAddress == null ) {
           $(this).trigger("failure", ["You need to specify an email address!"])
           return false;
         }
         var token = $.token();
         $.post("/mailing_list", {email: emailAddress, authenticity_token: token}, function(response, status, xhr){
           if(response.error){
             $(mailingList2).trigger("failure", ["An error occurred: " + response.error]);
           } else {
             $(mailingList2).trigger("success");
           }
         }, "json")
         .error(function(){
           $(mailingList2).trigger("failure", ["An error occurred. Please try again in a few minutes."]);
         });
       });
  
  
     mailingList2.find("form").submit(function(){
       emailAddress = mailingList2.find("input[name='email']").val();
       $(mailingList2).trigger("submittal", [emailAddress]);
       return false;
     });
  
     var mlSetting = $.cookie("mailingListSubmitted");
     if ( mlSetting == "true" ) {
       mailingList2.remove();
     }
   }
  
   // Mailing List Watcher
   var mailingList = $("#mailing-list");
   if ( mailingList.length ) {
     mailingList
       .live("completed", function(e){
       })
       .live("success", function(e){
         var that = this;
         $.cookie("mailingListSubmitted", "true", {expires: 7});
         if(mailingList.find("#status").length == 0){
           mailingList
             .find("form input[type='text']")
             .after($("&lt;div&gt;&lt;/div&gt;").attr({id : "status"}))
         }
         mailingList
           .find("form input[type='text']")
             .attr("disabled", true)
             .fadeOut(5000);
         $("#status")
           .text("Email submitted successfully!")
           .effect("highlight", { }, 1000);
       })
       .live("failure", function(e, error){
        if(mailingList.find("#status").length == 0){
           mailingList
             .find("form input[type='text']")
             .after($("&lt;div&gt;&lt;/div&gt;").attr({id : "status"}))
         }
         $("#status")
           .text(error)
           .effect("highlight", {}, 1000);
       })
       .live("submittal", function(e, emailAddress){
         if ( emailAddress == "" || emailAddress == null ) {
           $(this).trigger("failure", ["You need to specify an email address!"])
           return false;
         }
         var token = $.token();
         $.post("/mailing_list", {email: emailAddress, authenticity_token: token}, function(response, status, xhr){
           if(response.error){
             $(mailingList).trigger("failure", ["An error occurred: " + response.error]);
           } else {
             $(mailingList).trigger("success");
           }
         }, "json")
         .error(function(){
           $(mailingList).trigger("failure", ["An error occurred. Please try again in a few minutes."]);
         });
       });
  
  
     mailingList.find("form").submit(function(){
       emailAddress = mailingList.find("input[name='email']").val();
       $(mailingList).trigger("submittal", [emailAddress]);
       return false;
     });
  
     var mlSetting = $.cookie("mailingListSubmitted");
     if ( mlSetting == "true" ) {
       mailingList.remove();
     }
  }
  </code></pre>