OSDN Git Service

Merge branch 'v05' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v05
[pettanr/pettanr.git] / app / models / artist.rb
index 33ce5ba..1da4e38 100644 (file)
@@ -7,6 +7,15 @@ class Artist < ActiveRecord::Base
   validates :name, :presence => true, :length => {:maximum => 30}
   validates :author_id, :numericality => {:allow_blank => true}
   
+  before_validation :valid_encode
+  
+  def valid_encode
+    ['name'].each do |a|
+      next if attributes[a] == nil
+      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
+    end
+  end
+  
   def supply_default
     self.name = 'no name' if self.name.blank?
   end