OSDN Git Service

add stub SongSearchForm
authorcake <cake@users.sourceforge.jp>
Mon, 6 Sep 2010 13:40:35 +0000 (22:40 +0900)
committercake <cake@users.sourceforge.jp>
Mon, 6 Sep 2010 13:40:35 +0000 (22:40 +0900)
app/controllers/songs_controller.rb
app/models/song.rb
app/models/song_search_form.rb [new file with mode: 0644]

index 3d0b8fb..308341b 100644 (file)
@@ -23,7 +23,17 @@ class SongsController < BaseController
   end
 
   def edit
-    @song = Song.find_by_id(params[:id])
+    @song = Song.active.find_by_id(params[:id])
     redirect_to songs_path if @song.blank?
   end
+
+  def list
+    @songs = Song.active.all
+  end
+
+  def search
+    song_search_form = SongSearchForm.new(params[:search])
+    conditions = song_search_form.conditions
+    @songs = Song.find(:all, conditions)
+  end
 end
index 9c960c2..210c631 100644 (file)
@@ -11,6 +11,8 @@ class Song < ActiveRecord::Base
 
   CODES = %w(A Ab Bb C Cm D E Eb Em F F#m Fm G)
 
+  named_scope :active, :conditions => ["#{table_name}.deleted_at IS NULL"]
+
   validates_presence_of :titile, :words, :font_size
   validates_numericality_of :font_size
 
diff --git a/app/models/song_search_form.rb b/app/models/song_search_form.rb
new file mode 100644 (file)
index 0000000..a4b8fef
--- /dev/null
@@ -0,0 +1,8 @@
+class SongSearchForm
+  def initialize(args)
+  end
+
+  def options
+    {}
+  end
+end