From: shimada Date: Sat, 15 May 2010 08:58:43 +0000 (+0900) Subject: index画面ができた X-Git-Url: http://git.osdn.net/view?p=praisedb%2Fpraisedb.git;a=commitdiff_plain;h=13770e6b94c8d67241c81b591a5ba91bc04b6897 index画面ができた --- diff --git a/app/controllers/songs_controller.rb b/app/controllers/songs_controller.rb index 6755560..5246677 100644 --- a/app/controllers/songs_controller.rb +++ b/app/controllers/songs_controller.rb @@ -1,2 +1,9 @@ -class SongsController < ApplicationController +class SongsController < BaseController +def index +end + +def new + @song = Song.new +end + end diff --git a/app/helpers/songs_helper.rb b/app/helpers/songs_helper.rb index 75baad2..e3696c2 100644 --- a/app/helpers/songs_helper.rb +++ b/app/helpers/songs_helper.rb @@ -1,2 +1,29 @@ module SongsHelper + HIRAGANA = %w( + あ い う え お か き く け こ さ し す せ そ @ + た ち つ て と な に ぬ ね の は ひ ふ へ ほ @ + ま み む め も や ゆ よ ら り る れ ろ @ + わ @ + ) + KATAKANA = %w( + ア イ ウ エ オ カ キ ク ケ コ サ シ ス セ ソ @ + タ チ ツ テ ト ナ ニ ヌ ネ ノ ハ ヒ フ ヘ ホ @ + マ ミ ム メ モ ヤ ユ ヨ ワ リ ル レ ロ @ + ワ @ + ) + ROMAN = %w( + A B C D E F G H I J K L M N @ + O P Q R S T U V W X Y Z + ) + SENTINEL = '@' + + def letter_links(kind) + kind.map do |char| + unless char == SENTINEL + link_to char, list_songs_path(:letter => char) + else + '
' + end + end.join " " + end end diff --git a/app/views/song/index.html.erb b/app/views/song/index.html.erb deleted file mode 100644 index 001239c..0000000 --- a/app/views/song/index.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% content_for :head do -%> - Praise DATABASE -<% end -%> -

Praise DATABASE

- -<% form_for :search, :url => search_song_url do |f| -%> - <%= f.label :word, '検索(search)' %> - <%= f.text_field 'word' -%> - <%= f.submit 'search' %> -<% end -%> diff --git a/app/views/songs/index.html.erb b/app/views/songs/index.html.erb new file mode 100644 index 0000000..fa4379e --- /dev/null +++ b/app/views/songs/index.html.erb @@ -0,0 +1,25 @@ +<% content_for :head do -%> + Praise DATABASE +<% end -%> +

Praise DATABASE

+ +<% form_for :search, :url => search_songs_path do |f| -%> + <%= f.label :word, '検索' %> + <%= f.text_field 'word' -%> + <%= f.submit 'search' %> +<% end -%> + +

歌いだしインデックス
+First Letter Indexes

+ +<%= letter_links(SongsHelper::HIRAGANA) %> +<%= letter_links(SongsHelper::KATAKANA) %> +<%= letter_links(SongsHelper::ROMAN) %> + +

操作
Operations

+ + diff --git a/config/routes.rb b/config/routes.rb index d35527e..1ba78b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,6 @@ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. - map.resources :songs + map.resources :songs, :collection => { :search => [:get], :list => [:get] } # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view'