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
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
--- /dev/null
+<table border=1>
+ <tr>
+ <th nowrap>ID</th>
+ <th nowrap>CODE<br>コード</th>
+ <th nowrap>SIZE<br>サイズ</th>
+ <th>TITLE<br>タイトル</th>
+ <th nowrap>LAST UPDATE<br>最終更新</th>
+ <th nowrap colspan="3">OPERATIONS<br>各種操作</th>
+ </tr>
+ <%- @songs.each do |song| -%>
+ <tr>
+ <td><%=h song.id %></td>
+ <td><%=h song.code %></td>
+ <td><%=h song.font_size_name %></td>
+ <td><%=h song.title %></td>
+ <td><%=l song.updated_at %></td>
+ <td>
+ <%= link_to('EDIT', edit_song_path(song)) %>
+ <%= link_to('DEL', song, :confirm => '本当に削除しますか?', :method => :delete) %>
+ <%= link_to('PDF') %>
+ <%= link_to('MP3') %>
+ </td>
+ </tr>
+ <%- end -%>
+</table>