From 883dad64e9063e1b8df5be374fe02aa323ae0bda Mon Sep 17 00:00:00 2001 From: cake Date: Mon, 6 Sep 2010 22:40:35 +0900 Subject: [PATCH] add stub SongSearchForm --- app/controllers/songs_controller.rb | 12 +++++++++++- app/models/song.rb | 2 ++ app/models/song_search_form.rb | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/models/song_search_form.rb diff --git a/app/controllers/songs_controller.rb b/app/controllers/songs_controller.rb index 3d0b8fb..308341b 100644 --- a/app/controllers/songs_controller.rb +++ b/app/controllers/songs_controller.rb @@ -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 diff --git a/app/models/song.rb b/app/models/song.rb index 9c960c2..210c631 100644 --- a/app/models/song.rb +++ b/app/models/song.rb @@ -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 index 0000000..a4b8fef --- /dev/null +++ b/app/models/song_search_form.rb @@ -0,0 +1,8 @@ +class SongSearchForm + def initialize(args) + end + + def options + {} + end +end -- 2.11.0