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
Additional attr_accessible Rails 4 fix

attr_accessible may still be present, but implemented as a method that only
throws an exception to indicate that attr_accessible is deprecated. Catch this
exception in these cases.