Created
          March 13, 2015 15:26 
        
      - 
      
- 
        Save ckozus/42a7dbf6cc9385de2367 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class User | |
| has_one :plan | |
| has_many :certificates | |
| def remaining_certificates | |
| plan.available - certificates.current_month.count | |
| end | |
| end | |
| class Certificate | |
| belongs_to :user | |
| scope :current_month, -> { where(:created_at => [Time.zone.now.beggining_of_moth, Time.zone.now.end_of_moth]) } | |
| end | |
| class Plan < User | |
| belongs_to :user | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment