Archive for September, 2009
If for whatever reason the foreign key is invalid for a belongs_to relationship in ActiveRecord then the relationship is silently ignored. This results in object.relationship.method calls failing with nil errors and is quite frustrating to debug as no attempt to load the related object is logged.
Given this if a related object which is listed as a belongs_to in the model yet doesn’t work check that either the manual :foreign_key or the automatically determined version i.e. name + ‘_id’ exists in the dependencies table.
When moving to using php-fpm to serve pages via nginx from apache, its not very obvious how to see errors logged via the php function error_log, so I thought I’d post how to do it here so others don’t have to do quite a much searching as I did.
Its really simple just ensure both the following php variables are set:
This can be done either in the php.ini but the method I prefer is setting it up in php-fpm.conf e.g.
<?xml version="1.0" ?> <configuration> <workers> <section name="pool"> <value name="php_defines"> <value name="error_log">/var/log/php-error.log</value> <value name="log_errors">true</value> </value> </section> </workers> </configuration>