Lukkor

bought_detail.rb

Apr 11th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.47 KB | None | 0 0
  1. class BoughtDetail < ActiveRecord::Base
  2.     belongs_to :entry_type
  3.     belongs_to :person
  4.     before_save :set_bought_data, :set_end_on, :set_start_on
  5.  
  6.     attr_accessor :credit_card, :card_code, :days
  7.  
  8.     def set_bought_data
  9.         self.bought_data = Date.today
  10.     end
  11.  
  12.     def set_start_on
  13.       self.start_on = bought_data if start_on.nil?
  14.     end
  15.  
  16.     def set_end_on
  17.         days = "7" if days.nil?
  18.         self.end_on = Date.today + days.to_i
  19.     end
  20. end
Advertisement
Add Comment
Please, Sign In to add comment