Rails 4 compatibility fixes

 * Use new find_or_create_by style
 * Only use attr_accessible where available
 * Adapt to parameterized query style in SQL logging