Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. class Customer < ActiveRecord::Base
  2. has_many :settings, inverse_of: :customer, dependent: :destroy do
  3. def prepare_setting(api_setting)
  4. find_or_initialize_by(api_id: api_setting[:api_id]).tap do |api_set|
  5. api_set.description = api_setting[:description]
  6. # Some other stuff here
  7. end
  8. end
  9. end
  10.  
  11. def prepare_settings
  12. API.settings.each do |api_setting|
  13. settings.prepare_setting(api_setting)
  14. end
  15. end
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement