summaryrefslogtreecommitdiff
path: root/app/models/item_infix.rb
blob: cc99ee70a6091278edaf4670c361dd0892c8e261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class ItemInfix < ApplicationRecord
  belongs_to :character
  belongs_to :item
  belongs_to :skill

  before_create :check_max_infixes

  private
    def check_max_infixes
      current_infixes = character.item_infixes.where(skill: skill)
      raise :abort if current_infixes.count >= character.max_infixes(skill)
    end
end