Guest User

Untitled

a guest
Jul 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. class Card < ActiveRecord::Base
  2. translates :title, :description
  3. belongs_to :card_image, :include => true, :autosave => true, :dependent => :destroy, :validate => true
  4. belongs_to :card_type, :include => true
  5. belongs_to :card_rarity, :include => true
  6. serialize :script
  7.  
  8. validates_presence_of :alias
  9. validates_uniqueness_of :alias, :case_sensitive => false
  10. validates_format_of :alias, :with => /[a-z_][a-z0-9_-]*/i
  11. validates_presence_of :title
  12. validates_uniqueness_of :title
  13. validates_associated :card_image
  14. validates_presence_of :description
  15. validates_presence_of :price
  16. validates_numericality_of :price, :only_integer => true, :greater_than_or_equal_to => 0
  17. validates_presence_of :cost
  18. validates_numericality_of :cost, :only_integer => true, :greater_than_or_equal_to => 0
  19. validates_presence_of :move
  20. validates_numericality_of :move, :only_integer => true, :greater_than_or_equal_to => 0
  21. validates_associated :card_type
  22. validates_associated :card_rarity
  23.  
  24. def enabled?(type)
  25. card_type.script[:disable] != type && script[:disable] != type
  26. end
  27. end
Add Comment
Please, Sign In to add comment