OSDN Git Service

const to method
authorcake <cake@mini.local>
Sun, 29 Aug 2010 11:46:05 +0000 (20:46 +0900)
committercake <cake@mini.local>
Sun, 29 Aug 2010 11:46:05 +0000 (20:46 +0900)
app/controllers/songs_controller.rb
app/models/song.rb

index dfaba3e..3d0b8fb 100644 (file)
@@ -4,7 +4,7 @@ class SongsController < BaseController
 
   def new
     @song = Song.new
-    @song.font_size = Song::DEFAULT_FONT_SIZE
+    @song.font_size = Song.default_font_size
   end
 
   def create
index 33a5e76..9c960c2 100644 (file)
@@ -1,9 +1,6 @@
 class Song < ActiveRecord::Base
   include ::SelectableAttr::Base
 
-  DEFAULT_FONT_SIZE = 2
-  CODES = %w(A Ab Bb C Cm D E Eb Em F F#m Fm G)
-
   selectable_attr :font_size do
     entry "0", :xsmall, 'XSmall'
     entry "1", :small, 'Small'
@@ -12,9 +9,12 @@ class Song < ActiveRecord::Base
     entry "4", :xlarge, 'XLarge'
   end
 
-# validates_presence_of :titile, :words, :font_size
-# validates_numericality_of :font_size
-  def kana
-    self.words
+  CODES = %w(A Ab Bb C Cm D E Eb Em F F#m Fm G)
+
+  validates_presence_of :titile, :words, :font_size
+  validates_numericality_of :font_size
+
+  def self.default_font_size
+    self.font_size_id_by_key(:middle)
   end
 end