Tracing back to my webapp, it looks like the error was due to jQuery expecting a callback from my Rails AJAX method. It times out automatically after a few seconds, but if you click on another link immediately after it will generate additional HTML headers. To fix this, I added a new response to the script as a JSON.

In my Rails app, I added the following line to the corresponding method in the controller:render json: nil, status: :ok

Ruby 3+

I didn’t have to make any additional changes on the jQuery script. The following worked for me without any issue:$.ajax({
url : "/myapp/myajaxscript",
type: "POST",
data : formData,
success: function(data,status)
{
console.log(status);
}
});

Share this:

In order to use nested attributes in Rails 4, one must use the params.require method inside controller with the _attributes keyword and the list of fields inside the nested model. This is a good option if the keys of the nested models are known.

Here’s a simplified version of what it would look like. The question_params method inside the controller will have the nested model answer setup with answer_attributes: [:id, :response].

Adding the ‘activerecord-jdbcmysql-adapter’ gem and commenting out the original “mysql2” gem fixed the issue. I recommend using the “warble executable war” to troubleshoot these errors since you can quickly run a “java -jar myapp.war” to test it out.

Installation Notes:

There are a few changes that I needed to make to get it working properly with my app.

Set the passenger temp folder to /var/run/rubygem-passenger instead of /tmp/ in the Apache config. (/etc/httpd/conf.d/passenger.conf)

PassengerTempDir /var/run/rubygem-passenger

The reason behind this is due to the SELINUX permissions on the parent /tmp folder will not work properly. If you don’t have the PassengerTempDir set in Apache, you will get an error of a temp folder not being set when running “grep httpd /var/log/audit/audit.log | audit2allow -M passenger“

Here’s the permissions I have for the rubygem-passenger folder:

rvm rvm system_u:object_r:httpd_var_run_t:s0 rubygem-passenger

Set the permissions of the /myrailsapp/tmp folder

If you are using compiled CSS libraries such as Compass, you will need to set the proper SELINUX permissions for the compiled assets folder. Otherwise, any changes to the compiled css files will cause a fatal error in your application (read failure in the tmp folder).

Still having issues with the install? Here’s some fixes:

Error: Cannot stat ‘/var/run/rubygem-passenger/passenger.1.0.19162’: Permission deniedFix: This is due to SELINUX blocking access to the folder. Run the “grep httpd /var/log/audit/audit.log | audit2allow -M passenger” after changing setenforce to 0, restarting httpd, and adding the policy via semanage -i passenger.pp.

Error: Cannot change the directory ‘/tmp/passenger.1.0.—/generation-0/buffered_uploads’ its UID to 48 and GID to 48
Fix: This is a regular user permission issue (User/Group needs to have write permissions) and is also related to not using /var/run/rubygem-passenger

Error: Errno::EACCES Permission Denied
Fix: Your /[myrailsapp]/tmp folder permissions is incorrect. Compiled CSS libraries use the /[myrailsapp]/tmp folder to save all the data This could be either the user/group permissions or the SELINUX. The fastest way to check to see if its a SELINUX issue is setting setenforce to 0 and restarting httpd. If the app works, then you will need to set the /[myrailsapp]/tmp folder permissions. If not, check to see that the folder has global read/write permissions.