fixes for writing in m2m fields using Rails API