From 8f3c5075a0365fbe446a90036adf2e7ae10dea5f Mon Sep 17 00:00:00 2001 From: shimada Date: Thu, 21 Oct 2010 11:36:37 +0900 Subject: [PATCH] =?utf8?q?=E4=B8=80=E8=A6=A7=E3=81=A8=E5=89=8A=E9=99=A4?= =?utf8?q?=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + app/controllers/songs_controller.rb | 12 +++++++++++- app/models/song.rb | 6 +++++- app/views/songs/list.html.erb | 25 +++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 app/views/songs/list.html.erb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a01ee28 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*.swp diff --git a/app/controllers/songs_controller.rb b/app/controllers/songs_controller.rb index 35c6b3a..b96c918 100644 --- a/app/controllers/songs_controller.rb +++ b/app/controllers/songs_controller.rb @@ -38,8 +38,18 @@ class SongsController < BaseController return redirect_to :action => :edit end + def destroy + @song = Song.find(params[:id]) + @song.destroy + redirect_to song_url + end + def list - @songs = Song.active.all + if params[:letter] + @songs = Song.active.begin_with(params[:letter]) + else + @songs = Song.active.all + end end def search diff --git a/app/models/song.rb b/app/models/song.rb index 34118e1..ec5c797 100644 --- a/app/models/song.rb +++ b/app/models/song.rb @@ -26,8 +26,12 @@ class Song < ActiveRecord::Base font_size_id_by_key(:middle) end + def self.begin_with(letter) + self.find(:all, :conditions => ["words_for_search LIKE ?", letter + '%'], :order => "id") + end + def make_words_for_search - words_for_search = words + kana + words_for_search = kana + words end def kana diff --git a/app/views/songs/list.html.erb b/app/views/songs/list.html.erb new file mode 100644 index 0000000..612592e --- /dev/null +++ b/app/views/songs/list.html.erb @@ -0,0 +1,25 @@ + + + + + + + + + + <%- @songs.each do |song| -%> + + + + + + + + + <%- end -%> +
IDCODE
コード
SIZE
サイズ
TITLE
タイトル
LAST UPDATE
最終更新
OPERATIONS
各種操作
<%=h song.id %><%=h song.code %><%=h song.font_size_name %><%=h song.title %><%=l song.updated_at %> + <%= link_to('EDIT', edit_song_path(song)) %> + <%= link_to('DEL', song, :confirm => '本当に削除しますか?', :method => :delete) %> + <%= link_to('PDF') %> + <%= link_to('MP3') %> +
-- 2.11.0