OSDN Git Service

t#30505:fix token broken problem
authoryasushiito <yas@pen-chan.jp>
Sun, 20 Jan 2013 09:44:54 +0000 (18:44 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 20 Jan 2013 09:44:54 +0000 (18:44 +0900)
app/models/provider_status.rb

index 3902804..2ef6510 100644 (file)
@@ -1,12 +1,16 @@
 class ProviderStatus < ActiveRecord::Base
   has_one :provider
   
-#  validates :token
+  validates :token, :format => {:with => /^[a-zA-Z0-9]+$/, :allow_blank => true}
   validates :receive_hour1, :numericality => {:allow_blank => true}
   validates :receive_hour2, :numericality => {:allow_blank => true}
 #  validates :received_at
 #  validates :stopped_at
   
+  before_save do |r|
+    r.token = r.token.gsub(/\s/, '') if r.token
+  end
+  
   def supply_default
   end