Guest User

Untitled

a guest
Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. id
  2. subject
  3. message
  4. valediction
  5. sent_people_count
  6. deliver_by
  7. geotarget
  8. event_id
  9. list_id
  10. processed_at
  11. deleted_at
  12. created_at
  13. updated_at
  14.  
  15. class Notification < ActiveRecord::Base
  16. # common methods/validations/associations
  17. ...
  18.  
  19. def self.relate_to_details
  20. class_eval <<-EOF
  21. has_one :details, :class_name => "#{self.class.name}Detail"
  22. accepts_nested_attributes_for :details
  23. default_scope :include => :details
  24. EOF
  25. end
  26. end
  27.  
  28. class SMS < Notification
  29. relate_to_details
  30.  
  31. # sms specific methods
  32. ...
  33. end
  34.  
  35. class Twitter < Notification
  36. relate_to_details
  37.  
  38. # twitter specific methods
  39. ...
  40. end
  41.  
  42. class Email < Notification
  43.  
  44. # email specific methods
  45. ...
  46. end
  47.  
  48. class SMSDetail < ActiveRecord::Base
  49. belongs_to :SMS, :class_name => "SMS"
  50.  
  51. # sms specific validations
  52. ...
  53. end
  54.  
  55. class TwiterDetail < ActiveRecord::Base
  56. belongs_to :twitter
  57.  
  58. # twitter specific validations
  59. ...
  60. end
  61.  
  62. has_one :details, :class_name => "#{self.class.name}Detail"
  63.  
  64. has_one :details, :class_name => "#{self.name}Detail"
Add Comment
Please, Sign In to add comment