Guest User

Untitled

a guest
Jul 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. module ArExtensions
  2. def create_or_update(attributes)
  3. id = attributes[:id]
  4. if (record = find(id)).present?
  5. record.update_attributes(attributes.except(:id))
  6. else
  7. create(attributes)
  8. end
  9. end
  10. end
  11.  
  12. ActiveRecord::Base.extend(ArExtensions)
Add Comment
Please, Sign In to add comment