OSDN Git Service

Add Unit model, and many fixes to use it
[mint/mint-server.git] / app / models / unit.rb
1 class Unit < ActiveRecord::Base
2
3   has_many :problmes
4
5   validates_presence_of :name
6   validates_length_of :name, :maximum => 40
7
8   validates_presence_of   :symbol
9   validates_length_of     :symbol, :maximum => 40, :allow_nil => true
10   validates_format_of     :symbol, :with => /\A[a-z_]+\z/
11   validates_uniqueness_of :symbol
12
13   def generator(amount)
14     Mint::Generator::Factory.create(symbol, amount)
15   end
16
17   def solver
18     Mint::Solver::Maxima::Factory.create(symbol)
19   end
20 end