Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module ArExtensions
- def create_or_update(attributes)
- id = attributes[:id]
- if (record = find(id)).present?
- record.update_attributes(attributes.except(:id))
- else
- create(attributes)
- end
- end
- end
- ActiveRecord::Base.extend(ArExtensions)
Add Comment
Please, Sign In to add comment