<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ゾウ科マンモス属Zo-i種</title>
	<atom:link href="http://www.zo-i.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zo-i.com</link>
	<description>Ruby on Railsを中心に勉強中です。Blogタイトルはマンモス好きなためで、内容にはあまり関係ありません。</description>
	<lastBuildDate>Sun, 04 Apr 2010 09:59:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ruby-openidのテスト &#8211; ca14</title>
		<link>http://www.zo-i.com/project004cpro01/ruby-openid%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88-ca14.html</link>
		<comments>http://www.zo-i.com/project004cpro01/ruby-openid%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88-ca14.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 00:43:34 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=626</guid>
		<description><![CDATA[openid用のモジュール ruby-openid をインストール後、添付のサンプルアプリケーションを実行してみる。
■gemでruby-openidをインストール

C:\>gem install ruby-openi [...]]]></description>
			<content:encoded><![CDATA[<p>openid用のモジュール ruby-openid をインストール後、添付のサンプルアプリケーションを実行してみる。</p>
<h1>■gemでruby-openidをインストール</h1>
<blockquote><p>
C:\>gem install ruby-openid<br />
Successfully installed ruby-openid-2.1.7<br />
1 gem installed<br />
Installing ri documentation for ruby-openid-2.1.7&#8230;<br />
Installing RDoc documentation for ruby-openid-2.1.7&#8230;</p>
<p>C:\>
</p></blockquote>
<h1>■サンプルアプリケーションをコピー</h1>
<p>以下のフォルダを任意のフォルダにコピーする。</p>
<blockquote><p>
C:\Ruby\lib\ruby\gems\1.8\gems\ruby-openid-2.1.7\examples\rails_openid
</p></blockquote>
<h1>■セッションCookieの設定を追加</h1>
<p>サンプルアプリコードでは、Rails2.0以降で利用するためのセッションCookieの設定が記載されていないため、config\environment.rbを編集</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# Be sure to restart your web server when you modify this file.

# Uncomment below to force Rails into production mode when
# you don&#039;t control web/app server and can&#039;t set it the proper way
# ENV[&#039;RAILS_ENV&#039;] ||= &#039;production&#039;

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), &#039;boot&#039;)

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence those specified here

  # Skip frameworks you&#039;re not going to use
  # config.frameworks -= [ :action_web_service, :action_mailer ]

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Force all environments to use the same logger level
  # (by default production uses :info, the others :debug)
  # config.log_level = :debug

  # Use the database for sessions instead of the file system
  # (create the session table with &#039;rake create_sessions_table&#039;)
  # config.action_controller.session_store = :active_record_store

	config.action_controller.session = {
	    :key =&gt; &#039;_openid_session&#039;,
	    :secret      =&gt; &#039;c67504f48lfjaldkjaeiroeldakdhfkada&#039;
	  }

  # Enable page/fragment caching by setting a file-based store
  # (remember to create the caching directory and make it readable to the application)
  # config.action_controller.fragment_cache_store = :file_store, &quot;#{RAILS_ROOT}/cache&quot;

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector

  # Make Active Record use UTC-base instead of local time
  # config.active_record.default_timezone = :utc

  # Use Active Record&#039;s schema dumper instead of SQL when creating the test database
  # (enables use of different database adapters for development and test environments)
  # config.active_record.schema_format = :ruby

  # See Rails::Configuration for more options
end

# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
#   inflect.plural /^(ox)$/i, &#039;\1en&#039;
#   inflect.singular /^(ox)en/i, &#039;\1&#039;
#   inflect.irregular &#039;person&#039;, &#039;people&#039;
#   inflect.uncountable %w( fish sheep )
# end

# Include your application configuration below
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = &#039;_session_id_2&#039;
</pre>
<p>▲27～30行を追加</p>
<p>最初、Rails::Initializer.run メソッド内に記述していなかったため、軽くはまった。。。</p>
<h1>■実行結果</h1>
<p>サンプルアプリディレクトリでWeblickを実行</p>
<blockquote><p>
C:\rails_project\openid\rails_openid>ruby script/server<br />
=> Booting WEBrick<br />
=> Rails 2.3.3 application starting on http://0.0.0.0:3000</p>
<p>      *******************************************************************<br />
      * config.breakpoint_server has been deprecated and has no effect. *<br />
      *******************************************************************</p>
<p>=> Call with -d to detach<br />
=> Ctrl-C to shutdown server<br />
[2010-02-02 09:40:38] INFO  WEBrick 1.3.1<br />
[2010-02-02 09:40:38] INFO  ruby 1.8.6 (2008-08-11) [i386-mswin32]<br />
[2010-02-02 09:40:38] INFO  WEBrick::HTTPServer#start: pid=5636 port=3000
</p></blockquote>
<p><a href="http://www.zo-i.com/wp-content/uploads/2010/02/p20100202_01.jpg"><img src="http://www.zo-i.com/wp-content/uploads/2010/02/p20100202_01-500x375.jpg" alt="" title="p20100202_01" width="500" height="375" class="alignnone size-thumbnail wp-image-627" /></a><br />
▲http://localhost:3000/consumer　に接続</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/ruby-openid%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88-ca14.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>無料サーバ監視サービス &#8211; ca013</title>
		<link>http://www.zo-i.com/project004cpro01/%e7%84%a1%e6%96%99%e3%82%b5%e3%83%bc%e3%83%90%e7%9b%a3%e8%a6%96%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9-ca013.html</link>
		<comments>http://www.zo-i.com/project004cpro01/%e7%84%a1%e6%96%99%e3%82%b5%e3%83%bc%e3%83%90%e7%9b%a3%e8%a6%96%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9-ca013.html#comments</comments>
		<pubDate>Sun, 31 Jan 2010 06:37:16 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=624</guid>
		<description><![CDATA[■死活監視用の静的HTMLの準備
publicフォルダに静的HTMLを準備する。
■サーバ監視サービスに登録
監視用のURLを以下のサイトに登録
無料でも使えるIPv6対応の一歩進んだサーバ監視サービス &#8211;  [...]]]></description>
			<content:encoded><![CDATA[<h1>■死活監視用の静的HTMLの準備</h1>
<p>publicフォルダに静的HTMLを準備する。</p>
<p class="lang-name">HTML</p>
<pre class="brush: html; auto-links: false;" style="margin:18px 0;">
&lt;!-- cpro01\public\ping.html --&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
    Test Contents
  &lt;/body&gt;
&lt;/html&gt;
</pre>
<h1>■サーバ監視サービスに登録</h1>
<p>監視用のURLを以下のサイトに登録</p>
<p><a href="http://www.siteeye.net/">無料でも使えるIPv6対応の一歩進んだサーバ監視サービス &#8211; サイトアイ | SITE EYE</a></p>
<h1>■参考サイト</h1>
<p>その他のサービスは以下のURL参照</p>
<p><a href="http://www.metamix.com/564.php">「サーバー監視サービス」をざっくり集めてみました *{M}+</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/%e7%84%a1%e6%96%99%e3%82%b5%e3%83%bc%e3%83%90%e7%9b%a3%e8%a6%96%e3%82%b5%e3%83%bc%e3%83%93%e3%82%b9-ca013.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>個別amazonアイテム表示ページの作成 &#8211; ca012</title>
		<link>http://www.zo-i.com/project004cpro01/%e5%80%8b%e5%88%a5amazon%e3%82%a2%e3%82%a4%e3%83%86%e3%83%a0%e8%a1%a8%e7%a4%ba%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ae%e4%bd%9c%e6%88%90-ca012.html</link>
		<comments>http://www.zo-i.com/project004cpro01/%e5%80%8b%e5%88%a5amazon%e3%82%a2%e3%82%a4%e3%83%86%e3%83%a0%e8%a1%a8%e7%a4%ba%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ae%e4%bd%9c%e6%88%90-ca012.html#comments</comments>
		<pubDate>Tue, 19 Jan 2010 03:29:39 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=618</guid>
		<description><![CDATA[個別のamazonアイテム表示ページを作成
■検索結果Viewの編集
引き渡すasinコードを指定
▲36～39行目を編集
■books_controllerのshowメソッドを編集
Amazon::Ecsで個別アイテム [...]]]></description>
			<content:encoded><![CDATA[<p>個別のamazonアイテム表示ページを作成</p>
<h1>■検索結果Viewの編集</h1>
<p>引き渡すasinコードを指定</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\books\search.html.erb ---- %&gt;
&lt;p&gt;検索結果&lt;/p&gt;
タイトル：&lt;%= h params[:keyword] %&gt;&lt;br /&gt;
分類：&lt;%= h @search_v %&gt;&lt;br /&gt;
検索順：&lt;%= h @sort_v %&gt;&lt;br /&gt;
&lt;br /&gt;
再検索&lt;br /&gt;
&lt;% form_tag :action =&gt; &#039;search&#039; do %&gt;
  タイトル：&lt;%= text_field_tag &quot;keyword&quot;, params[:keyword] %&gt;&lt;br /&gt;
    分類：&lt;%= radio_button_tag &quot;search_index&quot;, &quot;Books&quot;, checked=@searchck[&quot;Books&quot;] %&gt;本
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;DVD&quot;, checked=@searchck[&quot;DVD&quot;] %&gt;DVD
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Music&quot;, checked=@searchck[&quot;Music&quot;] %&gt;音楽
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Software&quot;, checked=@searchck[&quot;Software&quot;] %&gt;ソフトウェア
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;VideoGames&quot;, checked=@searchck[&quot;VideoGames&quot;] %&gt;ゲーム&lt;br /&gt;

  検索順：&lt;%= radio_button_tag &quot;sort&quot;, &quot;salesrank&quot;, checked=@sortck[&quot;salesrank&quot;] %&gt;売れている順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;releasedate&quot;, checked=@sortck[&quot;releasedate&quot;] %&gt;発売日順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;titlerank&quot;, checked=@sortck[&quot;titlerank&quot;] %&gt;アルファベット順(AからZへ)
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;-titlerank&quot;, checked=@sortck[&quot;-titlerank&quot;] %&gt;アルファベット順(ZからAへ)&lt;br /&gt;
  &lt;%= submit_tag &quot;アマゾンで再検索&quot; %&gt;&lt;br /&gt;
&lt;% end %&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;% if @items &amp;&amp; @items.size &gt; 0 %&gt;
&lt;table&gt;
  &lt;% @items.each do |item| %&gt;

  &lt;tr&gt;
    &lt;td&gt;&lt;%= item.title %&gt;&lt;br /&gt;
        &lt;% if item.image != nil %&gt;
          &lt;%= link_to(image_tag(item.image[:url], :size =&gt; &quot;#{item.image[:width]}x#{item.image[:height]}&quot;, :alt =&gt; item.title), item.url, :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;&lt;br /&gt;
        &lt;%= item.asin %&gt;&lt;br /&gt;
        &lt;%= item.author %&gt;
      &lt;% form_tag :action =&gt; &quot;show&quot; do %&gt;
          &lt;%= hidden_field_tag(&quot;asin&quot;, item.asin) %&gt;
          &lt;%= submit_tag(&quot;このアイテムの地図データを登録&quot;) %&gt;
      &lt;% end %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
<p>▲36～39行目を編集</p>
<h1>■books_controllerのshowメソッドを編集</h1>
<p>Amazon::Ecsで個別アイテムの情報を取得</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\controllers\books_controller.rb ----

class BooksController &lt; ApplicationController
  # GET /books
  # GET /books.xml
  def index
    @books = Book.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =&gt; @books }
    end
  end

  # GET /books/1
  # GET /books/1.xml
  def show
    #amazon検索
    @res = Amazon::Ecs.item_lookup(params[:asin], {
    :response_group =&gt; &#039;Medium&#039;,
    }).items[0]

#    @book = Book.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/new
  # GET /books/new.xml
  def new
    @book = Book.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/1/edit
  def edit
    @book = Book.find(params[:id])
  end

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = &#039;Book was successfully created.&#039;
        format.html { redirect_to(@book) }
        format.xml  { render :xml =&gt; @book, :status =&gt; :created, :location =&gt; @book }
      else
        format.html { render :action =&gt; &quot;new&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # PUT /books/1
  # PUT /books/1.xml
  def update
    @book = Book.find(params[:id])

    respond_to do |format|
      if @book.update_attributes(params[:book])
        flash[:notice] = &#039;Book was successfully updated.&#039;
        format.html { redirect_to(@book) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # DELETE /books/1
  # DELETE /books/1.xml
  def destroy
    @book = Book.find(params[:id])
    @book.destroy

    respond_to do |format|
      format.html { redirect_to(books_url) }
      format.xml  { head :ok }
    end
  end

  def search
    #検索結果文言と再検索用の設定値を取得
    @searchck,@sortck,@search_v,@sort_v = makerb(params[:search_index],params[:sort])

    #本だけは「発売日順」でのソート用キーが他の物と違うため変更
    params[:sort] = &quot;daterank&quot; if params[:search_index] == &quot;Books&quot; &amp;&amp; params[:sort] == &quot;releasedate&quot;

    #Amazon商品検索
    res = Amazon::Ecs.item_search(params[:keyword], {
      :search_index =&gt; params[:search_index],
      :response_group =&gt; &#039;Medium&#039;,
      :sort =&gt; params[:sort]
    })
    @items = []
    res.items.each do |item|
      @items &lt;&lt; Item.new(
        item.get(&#039;asin&#039;),
        item.get(&#039;itemattributes/title&#039;),
        item.get(&#039;detailpageurl&#039;),
        item.get_hash(&#039;smallimage&#039;),
        item.get(&#039;author&#039;)
      )
    end
  end
end
</pre>
<p>▲18～23行目を追加</p>
<p>21行目で、items[0]に最初の要素を返すのがポイント</p>
<h1>■ShowのViewを編集</h1>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\books\show.html.erb ---- %&gt;
&lt;p&gt;
  &lt;b&gt;res:&lt;/b&gt;
&lt;table&gt;
  &lt;tr&gt;
    &lt;td Valign=&quot;top&quot;&gt;
        &lt;% if @res.get(&#039;mediumimage&#039;) != nil %&gt;
          &lt;%= link_to(image_tag(@res.get_hash(&#039;mediumimage&#039;)[:url], :alt =&gt; @res.get(&#039;title&#039;)), @res.get(&#039;detailpageurl&#039;), :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;%= @res.get(&#039;title&#039;) %&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;%= @res.get_array(&#039;author&#039;).join(&quot;,&quot;) %&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;&lt;%= @res.get(&#039;publisher&#039;) %&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/p&gt;

&lt;p&gt;
  &lt;b&gt;Asin:&lt;/b&gt;
  &lt;%#=h @book.asin %&gt;
&lt;/p&gt;

&lt;p&gt;
  &lt;b&gt;Del flg:&lt;/b&gt;
  &lt;%#=h @book.del_flg %&gt;
&lt;/p&gt;

&lt;%#= link_to &#039;Edit&#039;, edit_book_path(@book) %&gt; |
&lt;%= link_to &#039;Back&#039;, books_path %&gt;
</pre>
<h1>■実行結果</h1>
<p><a href="http://www.zo-i.com/wp-content/uploads/2010/01/p20100119_01.jpg"><img src="http://www.zo-i.com/wp-content/uploads/2010/01/p20100119_01-500x375.jpg" alt="" title="p20100119_01" width="500" height="375" class="alignnone size-thumbnail wp-image-619" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/%e5%80%8b%e5%88%a5amazon%e3%82%a2%e3%82%a4%e3%83%86%e3%83%a0%e8%a1%a8%e7%a4%ba%e3%83%9a%e3%83%bc%e3%82%b8%e3%81%ae%e4%bd%9c%e6%88%90-ca012.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>地図用のscaffold作成 &#8211; ca011</title>
		<link>http://www.zo-i.com/project004cpro01/%e5%9c%b0%e5%9b%b3%e7%94%a8%e3%81%aescaffold%e4%bd%9c%e6%88%90-ca011.html</link>
		<comments>http://www.zo-i.com/project004cpro01/%e5%9c%b0%e5%9b%b3%e7%94%a8%e3%81%aescaffold%e4%bd%9c%e6%88%90-ca011.html#comments</comments>
		<pubDate>Mon, 18 Jan 2010 12:49:37 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=613</guid>
		<description><![CDATA[地図用のscaffoldを作成した。
■scaffoldの実行

属性ペアに入力したのは以下の通り
▲各種ファイルの作成
■migrateファイルの編集
座標用のフィールド属性には追加したい事があるので、migrate用 [...]]]></description>
			<content:encoded><![CDATA[<p>地図用のscaffoldを作成した。</p>
<h1>■scaffoldの実行</h1>
<p><a href="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_02.jpg"><img src="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_02-500x327.jpg" alt="" title="p20100118_02" width="500" height="327" class="alignnone size-thumbnail wp-image-614" /></a></p>
<p>属性ペアに入力したのは以下の通り</p>
<p class="lang-name">Plain Text</p>
<pre class="brush: plain; auto-links: false;" style="margin:18px 0;">
book_id:integer user_id:integer la:decimal lo:decimal title:text comment:text tag:text netabare_flg:integer kokai_flg:integer nendai:string memo:text del_flg:integer
</pre>
<p class="lang-name">Plain Text</p>
<pre class="brush: plain; auto-links: false;" style="margin:18px 0;">
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/maps
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      exists  test/unit/helpers/
      exists  public/stylesheets/
      create  app/views/maps/index.html.erb
      create  app/views/maps/show.html.erb
      create  app/views/maps/new.html.erb
      create  app/views/maps/edit.html.erb
      create  app/views/layouts/maps.html.erb
   identical  public/stylesheets/scaffold.css
      create  app/controllers/maps_controller.rb
      create  test/functional/maps_controller_test.rb
      create  app/helpers/maps_helper.rb
      create  test/unit/helpers/maps_helper_test.rb
       route  map.resources :maps
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/map.rb
      create    test/unit/map_test.rb
      create    test/fixtures/maps.yml
      exists    db/migrate
      create    db/migrate/20100118123851_create_maps.rb
</pre>
<p>▲各種ファイルの作成</p>
<h1>■migrateファイルの編集</h1>
<p>座標用のフィールド属性には追加したい事があるので、migrate用ファイルを編集する。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\db\migrate\20100118123851_create_maps.rb ----
class CreateMaps &lt; ActiveRecord::Migration
  def self.up
    create_table :maps do |t|
      t.integer :book_id
      t.integer :user_id
      t.decimal :la, :precision =&gt; 18, :scale =&gt; 14, :default =&gt; 0
      t.decimal :lo, :precision =&gt; 18, :scale =&gt; 14, :default =&gt; 0
      t.text :title
      t.text :comment
      t.text :tag
      t.integer :netabare_flg
      t.integer :kokai_flg
      t.string :nendai
      t.text :memo
      t.integer :del_flg

      t.timestamps
    end
  end

  def self.down
    drop_table :maps
  end
end
</pre>
<p>▲7,8行目を編集</p>
<h1>■テーブル追加</h1>
<p>rake db:migrateを実行</p>
<p class="lang-name">Plain Text</p>
<pre class="brush: plain; auto-links: false;" style="margin:18px 0;">
(in C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01)
==  CreateMaps: migrating =====================================================
-- create_table(:maps)
   -&gt; 0.1570s
==  CreateMaps: migrated (0.1570s) ============================================
</pre>
<h1>■実行結果</h1>
<p><a href="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_03.jpg"><img src="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_03-500x375.jpg" alt="" title="p20100118_03" width="500" height="375" class="alignnone size-thumbnail wp-image-615" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/%e5%9c%b0%e5%9b%b3%e7%94%a8%e3%81%aescaffold%e4%bd%9c%e6%88%90-ca011.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>検索入力要素を元に、検索条件文言や再検索用情報を返すメソッドを追加 &#8211; ca010</title>
		<link>http://www.zo-i.com/project004cpro01/%e6%a4%9c%e7%b4%a2%e5%85%a5%e5%8a%9b%e8%a6%81%e7%b4%a0%e3%82%92%e5%85%83%e3%81%ab%e3%80%81%e6%a4%9c%e7%b4%a2%e6%9d%a1%e4%bb%b6%e6%96%87%e8%a8%80%e3%82%84%e5%86%8d%e6%a4%9c%e7%b4%a2%e7%94%a8%e6%83%85.html</link>
		<comments>http://www.zo-i.com/project004cpro01/%e6%a4%9c%e7%b4%a2%e5%85%a5%e5%8a%9b%e8%a6%81%e7%b4%a0%e3%82%92%e5%85%83%e3%81%ab%e3%80%81%e6%a4%9c%e7%b4%a2%e6%9d%a1%e4%bb%b6%e6%96%87%e8%a8%80%e3%82%84%e5%86%8d%e6%a4%9c%e7%b4%a2%e7%94%a8%e6%83%85.html#comments</comments>
		<pubDate>Mon, 18 Jan 2010 12:20:31 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=608</guid>
		<description><![CDATA[■新規メソッドの作成
Controllerから、検索分類や検索順情報を受け取り、表示用の文言やデフォルトチェック項目を返すメソッドを作成。
■Controllerの編集
メソッド化したところをシンプルに
▲89～100行 [...]]]></description>
			<content:encoded><![CDATA[<h1>■新規メソッドの作成</h1>
<p>Controllerから、検索分類や検索順情報を受け取り、表示用の文言やデフォルトチェック項目を返すメソッドを作成。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\lib\search_index.rb ----

def makerb(rbindex,rbsort)
  h1 = {&quot;Books&quot; =&gt; false, &quot;DVD&quot; =&gt; false, &quot;Music&quot; =&gt; false, &quot;Software&quot; =&gt; false, &quot;VideoGames&quot; =&gt; false}
  h2 = {&quot;salesrank&quot; =&gt; false, &quot;releasedate&quot; =&gt; false, &quot;titlerank&quot; =&gt; false, &quot;-titlerank&quot; =&gt; false}

  #デフォルトチェック用
  h1[rbindex] = true
  h2[rbsort] = true

  #検索した分類の表示文言
  case rbindex
  when &quot;Books&quot;
    se = &quot;本&quot;
  when &quot;DVD&quot;
    se = &quot;DVD&quot;
  when &quot;Music&quot;
    se = &quot;音楽&quot;
  when &quot;Software&quot;
    se = &quot;ソフトウェア&quot;
  when &quot;VideoGames&quot;
    se = &quot;ゲーム&quot;
  else
    se = &quot;None&quot;
  end

  #検索した分類の表示文言
  case rbsort
  when &quot;salesrank&quot;
    so = &quot;売れている順&quot;
  when &quot;releasedate&quot;
    so = &quot;発売日順&quot;
  when &quot;titlerank&quot;
    so = &quot;アルファベット順(AからZへ) &quot;
  when &quot;-titlerank&quot;
    so = &quot;アルファベット順(ZからAへ) &quot;
  else
    so = &quot;None&quot;
  end

  return h1, h2, se, so
end
</pre>
<h1>■Controllerの編集</h1>
<p>メソッド化したところをシンプルに</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\controllers\books_controller.rb ----

class BooksController &lt; ApplicationController
  # GET /books
  # GET /books.xml
  def index
    @books = Book.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =&gt; @books }
    end
  end

  # GET /books/1
  # GET /books/1.xml
  def show
    @book = Book.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/new
  # GET /books/new.xml
  def new
    @book = Book.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/1/edit
  def edit
    @book = Book.find(params[:id])
  end

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = &#039;Book was successfully created.&#039;
        format.html { redirect_to(@book) }
        format.xml  { render :xml =&gt; @book, :status =&gt; :created, :location =&gt; @book }
      else
        format.html { render :action =&gt; &quot;new&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # PUT /books/1
  # PUT /books/1.xml
  def update
    @book = Book.find(params[:id])

    respond_to do |format|
      if @book.update_attributes(params[:book])
        flash[:notice] = &#039;Book was successfully updated.&#039;
        format.html { redirect_to(@book) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # DELETE /books/1
  # DELETE /books/1.xml
  def destroy
    @book = Book.find(params[:id])
    @book.destroy

    respond_to do |format|
      format.html { redirect_to(books_url) }
      format.xml  { head :ok }
    end
  end

  def search
    #検索結果文言と再検索用の設定値を取得
    @searchck,@sortck,@search_v,@sort_v = makerb(params[:search_index],params[:sort])

    #本だけは「発売日順」でのソート用キーが他の物と違うため変更
    params[:sort] = &quot;daterank&quot; if params[:search_index] == &quot;Books&quot; &amp;&amp; params[:sort] == &quot;releasedate&quot;

    #Amazon商品検索
    res = Amazon::Ecs.item_search(params[:keyword], {
      :search_index =&gt; params[:search_index],
      :response_group =&gt; &#039;Medium&#039;,
      :sort =&gt; params[:sort]
    })
    @items = []
    res.items.each do |item|
      @items &lt;&lt; Item.new(
        item.get(&#039;asin&#039;),
        item.get(&#039;itemattributes/title&#039;),
        item.get(&#039;detailpageurl&#039;),
        item.get_hash(&#039;smallimage&#039;),
        item.get(&#039;author&#039;)
      )
    end
  end

end
</pre>
<p>▲89～100行目を編集</p>
<h1>■Veiwの編集</h1>
<p>検索時に入力した文言を表示。ついでに再検索用フォームも追加</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\books\search.html.erb ---- %&gt;
&lt;p&gt;検索結果&lt;/p&gt;
タイトル：&lt;%= h params[:keyword] %&gt;&lt;br /&gt;
分類：&lt;%= h @search_v %&gt;&lt;br /&gt;
検索順：&lt;%= h @sort_v %&gt;&lt;br /&gt;
&lt;br /&gt;
再検索&lt;br /&gt;
&lt;% form_tag :action =&gt; &#039;search&#039; do %&gt;
  タイトル：&lt;%= text_field_tag &quot;keyword&quot;, params[:keyword] %&gt;&lt;br /&gt;
    分類：&lt;%= radio_button_tag &quot;search_index&quot;, &quot;Books&quot;, checked=@searchck[&quot;Books&quot;] %&gt;本
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;DVD&quot;, checked=@searchck[&quot;DVD&quot;] %&gt;DVD
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Music&quot;, checked=@searchck[&quot;Music&quot;] %&gt;音楽
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Software&quot;, checked=@searchck[&quot;Software&quot;] %&gt;ソフトウェア
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;VideoGames&quot;, checked=@searchck[&quot;VideoGames&quot;] %&gt;ゲーム&lt;br /&gt;

  検索順：&lt;%= radio_button_tag &quot;sort&quot;, &quot;salesrank&quot;, checked=@sortck[&quot;salesrank&quot;] %&gt;売れている順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;releasedate&quot;, checked=@sortck[&quot;releasedate&quot;] %&gt;発売日順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;titlerank&quot;, checked=@sortck[&quot;titlerank&quot;] %&gt;アルファベット順(AからZへ)
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;-titlerank&quot;, checked=@sortck[&quot;-titlerank&quot;] %&gt;アルファベット順(ZからAへ)&lt;br /&gt;
  &lt;%= submit_tag &quot;アマゾンで再検索&quot; %&gt;&lt;br /&gt;
&lt;% end %&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;% if @items &amp;&amp; @items.size &gt; 0 %&gt;
&lt;table&gt;
  &lt;% @items.each do |item| %&gt;

  &lt;tr&gt;
    &lt;td&gt;&lt;%= item.title %&gt;&lt;br /&gt;
        &lt;% if item.image != nil %&gt;
          &lt;%= link_to(image_tag(item.image[:url], :size =&gt; &quot;#{item.image[:width]}x#{item.image[:height]}&quot;, :alt =&gt; item.title), item.url, :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;&lt;br /&gt;
        &lt;%= item.asin %&gt;&lt;br /&gt;
        &lt;%= item.author %&gt;
      &lt;% form_tag :controller =&gt; &quot;maps&quot;, :action =&gt; &quot;show&quot; do %&gt;
          &lt;%= hidden_field_tag(&quot;asin&quot;, item.asin) %&gt;
          &lt;%= hidden_field_tag(&quot;address&quot;, &quot;新宿&quot;) %&gt;
          &lt;%= submit_tag(&quot;このアイテムの地図データを登録&quot;) %&gt;
      &lt;% end %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
<p>▲2～23行目を追加</p>
<h1>■実行結果</h1>
<p><a href="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_01.jpg"><img src="http://www.zo-i.com/wp-content/uploads/2010/01/p20100118_01-500x375.jpg" alt="" title="p20100118_01" width="500" height="375" class="alignnone size-thumbnail wp-image-610" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/%e6%a4%9c%e7%b4%a2%e5%85%a5%e5%8a%9b%e8%a6%81%e7%b4%a0%e3%82%92%e5%85%83%e3%81%ab%e3%80%81%e6%a4%9c%e7%b4%a2%e6%9d%a1%e4%bb%b6%e6%96%87%e8%a8%80%e3%82%84%e5%86%8d%e6%a4%9c%e7%b4%a2%e7%94%a8%e6%83%85.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ライブラリ追加のテスト &#8211; ca009</title>
		<link>http://www.zo-i.com/project004cpro01/%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e8%bf%bd%e5%8a%a0%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88.html</link>
		<comments>http://www.zo-i.com/project004cpro01/%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e8%bf%bd%e5%8a%a0%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88.html#comments</comments>
		<pubDate>Wed, 13 Jan 2010 02:08:14 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=604</guid>
		<description><![CDATA[railsのライブラリ追加ルールを考えてみる。
■ライブラリファイルを作成
引数に2を加えて返すだけの関数を追加
■ライブラリ初期化用ファイルの作成
初期化時に上記ライブラリファイルを読み込むextensions.rbを [...]]]></description>
			<content:encoded><![CDATA[<p>railsのライブラリ追加ルールを考えてみる。</p>
<h1>■ライブラリファイルを作成</h1>
<p>引数に2を加えて返すだけの関数を追加</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\lib\search_index.rb ----

def pu(d)
  return(d + 2)
end
</pre>
<h1>■ライブラリ初期化用ファイルの作成</h1>
<p>初期化時に上記ライブラリファイルを読み込むextensions.rbを作成</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\config\initializers\extensions.rb ----

require &#039;search_index.rb&#039;
</pre>
<h1>■Controllerで関数呼び出し</h1>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\controllers\books_controller.rb ----

class BooksController &lt; ApplicationController
  # GET /books
  # GET /books.xml
  def index
    @books = Book.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =&gt; @books }
    end
  end

  # GET /books/1
  # GET /books/1.xml
  def show
    @book = Book.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/new
  # GET /books/new.xml
  def new
    @book = Book.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/1/edit
  def edit
    @book = Book.find(params[:id])
  end

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = &#039;Book was successfully created.&#039;
        format.html { redirect_to(@book) }
        format.xml  { render :xml =&gt; @book, :status =&gt; :created, :location =&gt; @book }
      else
        format.html { render :action =&gt; &quot;new&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # PUT /books/1
  # PUT /books/1.xml
  def update
    @book = Book.find(params[:id])

    respond_to do |format|
      if @book.update_attributes(params[:book])
        flash[:notice] = &#039;Book was successfully updated.&#039;
        format.html { redirect_to(@book) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # DELETE /books/1
  # DELETE /books/1.xml
  def destroy
    @book = Book.find(params[:id])
    @book.destroy

    respond_to do |format|
      format.html { redirect_to(books_url) }
      format.xml  { head :ok }
    end
  end

  def search
    @searchck = {&quot;Books&quot; =&gt; false, &quot;DVD&quot; =&gt; false, &quot;Music&quot; =&gt; false, &quot;Software&quot; =&gt; false, &quot;VideoGames&quot; =&gt; false}
    @sortck = {&quot;salesrank&quot; =&gt; false, &quot;releasedate&quot; =&gt; false, &quot;titlerank&quot; =&gt; false, &quot;-titlerank&quot; =&gt; false}

    @keyword = params[:keyword]
    @search_index = params[:search_index]
    @sort = params[:sort]

    #デフォルトチェック用
    @searchck[&quot;#{@search_index}&quot;] = true
    @sortck[&quot;#{@sort}&quot;] = true

    #本だけはソート用のキーが他の物と違うため変更
    @sort = &quot;daterank&quot; if @search_index == &quot;Books&quot; &amp;&amp; @sort == &quot;releasedate&quot;

    #検索
    res = Amazon::Ecs.item_search(@keyword, {
      :search_index =&gt; @search_index,
      :response_group =&gt; &#039;Medium&#039;,
      :sort =&gt; @sort
    })
    @items = []
    res.items.each do |item|
      @items &lt;&lt; Item.new(
        item.get(&#039;asin&#039;),
        item.get(&#039;itemattributes/title&#039;),
        item.get(&#039;detailpageurl&#039;),
        item.get_hash(&#039;smallimage&#039;),
        item.get(&#039;author&#039;)
      )
    end

    @testp = pu(5)
  end

end
</pre>
<p>▲追加したのは、最後の”@testp = pu(5)”のみ</p>
<h1>■Viewファイルに追加・確認</h1>
<p>@testpを表示してみる。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\books\search.html.erb ---- %&gt;
&lt;%= h @testp %&gt;
&lt;p&gt;検索結果&lt;/p&gt;
&lt;% if @items &amp;&amp; @items.size &gt; 0 %&gt;
&lt;table&gt;
  &lt;% @items.each do |item| %&gt;

  &lt;tr&gt;
    &lt;td&gt;&lt;%= item.title %&gt;&lt;br /&gt;
        &lt;% if item.image != nil %&gt;
          &lt;%= link_to(image_tag(item.image[:url], :size =&gt; &quot;#{item.image[:width]}x#{item.image[:height]}&quot;, :alt =&gt; item.title), item.url, :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;&lt;br /&gt;
        &lt;%= item.asin %&gt;&lt;br /&gt;
        &lt;%= item.author %&gt;
      &lt;% form_tag :controller =&gt; &quot;maps&quot;, :action =&gt; &quot;show&quot; do %&gt;
          &lt;%= hidden_field_tag(&quot;asin&quot;, item.asin) %&gt;
          &lt;%= hidden_field_tag(&quot;address&quot;, &quot;新宿&quot;) %&gt;
          &lt;%= submit_tag(&quot;この本の地図データを登録&quot;) %&gt;
      &lt;% end %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
<p>▲2行目を追加</p>
<p>検索結果の上に”7”が表示される事を確認。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa%e8%bf%bd%e5%8a%a0%e3%81%ae%e3%83%86%e3%82%b9%e3%83%88.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon APIの検索バリエーションを増やす &#8211; ca008</title>
		<link>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%ae%e6%a4%9c%e7%b4%a2%e3%83%90%e3%83%aa%e3%82%a8%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a2%97%e3%82%84%e3%81%99-ca008.html</link>
		<comments>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%ae%e6%a4%9c%e7%b4%a2%e3%83%90%e3%83%aa%e3%82%a8%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a2%97%e3%82%84%e3%81%99-ca008.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 09:35:39 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=601</guid>
		<description><![CDATA[キーワード以外にも、「本」「DVD」といった項目、および「売れている順」「発売日順」などのソート順を指定してAmazon検索ができるように拡張する。
■検索用フォームの追加
cpro01\app\views\top\in [...]]]></description>
			<content:encoded><![CDATA[<p>キーワード以外にも、「本」「DVD」といった項目、および「売れている順」「発売日順」などのソート順を指定してAmazon検索ができるように拡張する。</p>
<h1>■検索用フォームの追加</h1>
<p>cpro01\app\views\top\index.html.erbを編集し、検索入力項目を追加する。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\top\index.html.erb ---- %&gt;

&lt;h1&gt;Top#index&lt;/h1&gt;
&lt;p&gt;Find me in app/views/top/index.html.erb&lt;/p&gt;
&lt;%= @gmap.div(:width =&gt; 550, :height =&gt; 400) %&gt;

&lt;p&gt;Amazonから登録図書を検索&lt;/p&gt;
&lt;% form_tag :controller =&gt; &#039;books&#039;, :action =&gt; &#039;search&#039; do %&gt;
  タイトル：&lt;%= text_field_tag &quot;keyword&quot;, @keyword %&gt;&lt;br /&gt;
    分類：&lt;%= radio_button_tag &quot;search_index&quot;, &quot;Books&quot;, checked=true %&gt;本
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;DVD&quot; %&gt;DVD
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Music&quot; %&gt;音楽
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;Software&quot; %&gt;ソフトウェア
  &lt;%= radio_button_tag &quot;search_index&quot;, &quot;VideoGames&quot; %&gt;ゲーム&lt;br /&gt;

  検索順：&lt;%= radio_button_tag &quot;sort&quot;, &quot;salesrank&quot;, checked=true %&gt;売れている順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;releasedate&quot; %&gt;発売日順
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;titlerank&quot; %&gt;アルファベット順(AからZへ)
  &lt;%= radio_button_tag &quot;sort&quot;, &quot;-titlerank&quot; %&gt;アルファベット順(ZからAへ)&lt;br /&gt;
  &lt;%= submit_tag &quot;アマゾンで検索&quot; %&gt;&lt;br /&gt;
&lt;% end %&gt;
</pre>
<h1>■BooksControllerを編集</h1>
<p>入力項目処理を追加</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\controllers\books_controller.rb ----

class BooksController &lt; ApplicationController
  # GET /books
  # GET /books.xml
  def index
    @books = Book.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =&gt; @books }
    end
  end

  # GET /books/1
  # GET /books/1.xml
  def show
    @book = Book.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/new
  # GET /books/new.xml
  def new
    @book = Book.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/1/edit
  def edit
    @book = Book.find(params[:id])
  end

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = &#039;Book was successfully created.&#039;
        format.html { redirect_to(@book) }
        format.xml  { render :xml =&gt; @book, :status =&gt; :created, :location =&gt; @book }
      else
        format.html { render :action =&gt; &quot;new&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # PUT /books/1
  # PUT /books/1.xml
  def update
    @book = Book.find(params[:id])

    respond_to do |format|
      if @book.update_attributes(params[:book])
        flash[:notice] = &#039;Book was successfully updated.&#039;
        format.html { redirect_to(@book) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # DELETE /books/1
  # DELETE /books/1.xml
  def destroy
    @book = Book.find(params[:id])
    @book.destroy

    respond_to do |format|
      format.html { redirect_to(books_url) }
      format.xml  { head :ok }
    end
  end

  def search
    @searchck = {&quot;Books&quot; =&gt; false, &quot;DVD&quot; =&gt; false, &quot;Music&quot; =&gt; false, &quot;Software&quot; =&gt; false, &quot;VideoGames&quot; =&gt; false}
    @sortck = {&quot;salesrank&quot; =&gt; false, &quot;releasedate&quot; =&gt; false, &quot;titlerank&quot; =&gt; false, &quot;-titlerank&quot; =&gt; false}

    @keyword = params[:keyword]
    @search_index = params[:search_index]
    @sort = params[:sort]

    #デフォルトチェック用
    @searchck[&quot;#{@search_index}&quot;] = true
    @sortck[&quot;#{@sort}&quot;] = true

    #本だけはソート用のキーが他の物と違うため変更
    @sort = &quot;daterank&quot; if @search_index == &quot;Books&quot; &amp;&amp; @sort == &quot;releasedate&quot;

    #検索
    res = Amazon::Ecs.item_search(@keyword, {
      :search_index =&gt; @search_index,
      :response_group =&gt; &#039;Medium&#039;,
      :sort =&gt; @sort
    })
    @items = []
    res.items.each do |item|
      @items &lt;&lt; Item.new(
        item.get(&#039;asin&#039;),
        item.get(&#039;itemattributes/title&#039;),
        item.get(&#039;detailpageurl&#039;),
        item.get_hash(&#039;smallimage&#039;),
        item.get(&#039;author&#039;)
      )
    end
  end
end
</pre>
<h1>■検索結果を変更</h1>
<p>次の地図登録ページへの遷移用のボタンを追加</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\books\search.html.erb ---- %&gt;

&lt;p&gt;検索結果&lt;/p&gt;
&lt;% if @items &amp;&amp; @items.size &gt; 0 %&gt;
&lt;table&gt;
  &lt;% @items.each do |item| %&gt;

  &lt;tr&gt;
    &lt;td&gt;&lt;%= item.title %&gt;&lt;br /&gt;
        &lt;% if item.image != nil %&gt;
          &lt;%= link_to(image_tag(item.image[:url], :size =&gt; &quot;#{item.image[:width]}x#{item.image[:height]}&quot;, :alt =&gt; item.title), item.url, :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;&lt;br /&gt;
        &lt;%= item.asin %&gt;&lt;br /&gt;
        &lt;%= item.author %&gt;
      &lt;% form_tag :controller =&gt; &quot;maps&quot;, :action =&gt; &quot;show&quot; do %&gt;
          &lt;%= hidden_field_tag(&quot;asin&quot;, item.asin) %&gt;
          &lt;%= hidden_field_tag(&quot;address&quot;, &quot;新宿&quot;) %&gt;
          &lt;%= submit_tag(&quot;この本の地図データを登録&quot;) %&gt;
      &lt;% end %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%ae%e6%a4%9c%e7%b4%a2%e3%83%90%e3%83%aa%e3%82%a8%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3%e3%82%92%e5%a2%97%e3%82%84%e3%81%99-ca008.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon APIからのデータ取得 &#8211; ca007</title>
		<link>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%8b%e3%82%89%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97.html</link>
		<comments>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%8b%e3%82%89%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 07:51:35 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=596</guid>
		<description><![CDATA[■API Key他の初期設定
▲44～52行目を追加
■Modelの生成
ファイルのみ作成（generaterで生成するとActiveRecordを継承するため、利用しない）
■BooksControllerの編集
se [...]]]></description>
			<content:encoded><![CDATA[<h1>■API Key他の初期設定</h1>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\config\environment.rb ----

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = &#039;2.3.3&#039; unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), &#039;boot&#039;)

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those specified here.
  # Application configuration should go into files in config/initializers
  # -- all .rb files in that directory are automatically loaded.

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Specify gems that this application depends on and have them installed with rake gems:install
  # config.gem &quot;bj&quot;
  # config.gem &quot;hpricot&quot;, :version =&gt; &#039;0.6&#039;, :source =&gt; &quot;http://code.whytheluckystiff.net&quot;
  # config.gem &quot;sqlite3-ruby&quot;, :lib =&gt; &quot;sqlite3&quot;
  # config.gem &quot;aws-s3&quot;, :lib =&gt; &quot;aws/s3&quot;

  # Only load the plugins named here, in the order given (default is alphabetical).
  # :all can be used as a placeholder for all plugins not explicitly named
  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

  # Skip frameworks you&#039;re not going to use. To use Rails without a database,
  # you must remove the Active Record framework.
  # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector, :forum_observer

  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  # Run &quot;rake -D time&quot; for a list of tasks for finding time zone names.
  config.time_zone = &#039;UTC&#039;

  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
  # config.i18n.load_path += Dir[Rails.root.join(&#039;my&#039;, &#039;locales&#039;, &#039;*.{rb,yml}&#039;)]
  # config.i18n.default_locale = :de

  # amazon-ecs
  require &#039;amazon/ecs&#039;
  Amazon::Ecs.debug = true
  Amazon::Ecs.options = {
    :aWS_access_key_id =&gt; &quot;foo&quot;,
    :associate_tag =&gt; &quot;bar-22&quot;,
    :country =&gt; :jp,
    :aWS_secret_key =&gt; &quot;baz&quot;
  }
end
</pre>
<p>▲44～52行目を追加</p>
<h1>■Modelの生成</h1>
<p>ファイルのみ作成（generaterで生成するとActiveRecordを継承するため、利用しない）</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\models\item.rb ----

class Item
  attr_accessor :asin, :title, :url, :image, :author
  def initialize(asin, title = nil, url = nil, image = nil, author = nil)
    @asin = asin
    @title = title
    @url = url
    @image = image
    @author = author
  end
end
</pre>
<h1>■BooksControllerの編集</h1>
<p>searchメソッドを作成し、Amazon APIからデータを取得する。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\app\controllers\books_controller.rb ----

class BooksController &lt; ApplicationController
  # GET /books
  # GET /books.xml
  def index
    @books = Book.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml =&gt; @books }
    end
  end

  # GET /books/1
  # GET /books/1.xml
  def show
    @book = Book.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/new
  # GET /books/new.xml
  def new
    @book = Book.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml =&gt; @book }
    end
  end

  # GET /books/1/edit
  def edit
    @book = Book.find(params[:id])
  end

  # POST /books
  # POST /books.xml
  def create
    @book = Book.new(params[:book])

    respond_to do |format|
      if @book.save
        flash[:notice] = &#039;Book was successfully created.&#039;
        format.html { redirect_to(@book) }
        format.xml  { render :xml =&gt; @book, :status =&gt; :created, :location =&gt; @book }
      else
        format.html { render :action =&gt; &quot;new&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # PUT /books/1
  # PUT /books/1.xml
  def update
    @book = Book.find(params[:id])

    respond_to do |format|
      if @book.update_attributes(params[:book])
        flash[:notice] = &#039;Book was successfully updated.&#039;
        format.html { redirect_to(@book) }
        format.xml  { head :ok }
      else
        format.html { render :action =&gt; &quot;edit&quot; }
        format.xml  { render :xml =&gt; @book.errors, :status =&gt; :unprocessable_entity }
      end
    end
  end

  # DELETE /books/1
  # DELETE /books/1.xml
  def destroy
    @book = Book.find(params[:id])
    @book.destroy

    respond_to do |format|
      format.html { redirect_to(books_url) }
      format.xml  { head :ok }
    end
  end

  def search
    #キーワード取得
    @keyword = params[:keyword]

    #検索用初期値
    @search_index = &quot;Books&quot;
    @sort = &quot;daterank&quot;

    #検索
    res = Amazon::Ecs.item_search(@keyword, {
      :search_index =&gt; @search_index,
      :response_group =&gt; &#039;Medium&#039;,
      :sort =&gt; @sort
    })
    @items = []
    res.items.each do |item|
      @items &lt;&lt; Item.new(
        item.get(&#039;asin&#039;),
        item.get(&#039;itemattributes/title&#039;),
        item.get(&#039;detailpageurl&#039;),
        item.get_hash(&#039;smallimage&#039;),
        item.get(&#039;author&#039;)
      )
    end
  end
end
</pre>
<p>▲88～112行目を追加</p>
<h1>■Viewファイルの作成</h1>
<p>search.html.erbを手動で新規作成。</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;%# ---- cpro01\app\views\books\search.html.erb ---- %&gt;

&lt;p&gt;検索結果&lt;/p&gt;
&lt;% if @items &amp;&amp; @items.size &gt; 0 %&gt;
&lt;table&gt;
  &lt;% @items.each do |item| %&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;%= item.title %&gt;&lt;br /&gt;
        &lt;% if item.image != nil %&gt;
          &lt;%= link_to(image_tag(item.image[:url], :size =&gt; &quot;#{item.image[:width]}x#{item.image[:height]}&quot;, :alt =&gt; item.title), item.url, :target =&gt; &#039;_blank&#039;) %&gt;
        &lt;% end %&gt;&lt;br /&gt;
        &lt;%= item.asin %&gt;&lt;br /&gt;
        &lt;%= item.author %&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;% end %&gt;
&lt;% end %&gt;
&lt;/table&gt;
</pre>
<h1>■検索用キーワード入力欄を追加</h1>
<p>topのindex.html.erbに追加</p>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
&lt;% # ---- cpro01\app\views\top\index.html.erb ---- %&gt;

&lt;h1&gt;Top#index&lt;/h1&gt;
&lt;p&gt;Find me in app/views/top/index.html.erb&lt;/p&gt;
&lt;%= @gmap.div(:width =&gt; 550, :height =&gt; 400) %&gt;

&lt;p&gt;Amazonから登録図書を検索&lt;/p&gt;
&lt;% form_tag :controller =&gt; &#039;books&#039;, :action =&gt; &#039;search&#039; do %&gt;
  タイトル：&lt;%= text_field_tag &quot;keyword&quot;, @keyword %&gt;&lt;br /&gt;
  &lt;%= submit_tag &quot;アマゾンで検索&quot; %&gt;&lt;br /&gt;
&lt;% end %&gt;
</pre>
<p>▲7～11行目を追加</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/amazon-api%e3%81%8b%e3%82%89%e3%81%ae%e3%83%87%e3%83%bc%e3%82%bf%e5%8f%96%e5%be%97.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>erbファイルのコメントに関して &#8211; ca006</title>
		<link>http://www.zo-i.com/project004cpro01/erb%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%81%ab%e9%96%a2%e3%81%97%e3%81%a6-ca006.html</link>
		<comments>http://www.zo-i.com/project004cpro01/erb%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%81%ab%e9%96%a2%e3%81%97%e3%81%a6-ca006.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 03:20:35 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=593</guid>
		<description><![CDATA[ちょっとはまったので。。。
■コメント記述方法
■NG時のエラーメッセージ
]]></description>
			<content:encoded><![CDATA[<p>ちょっとはまったので。。。</p>
<h1>■コメント記述方法</h1>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
#OK
&lt;% # ---- cpro01\app\views\top\index.html.erb ---- %&gt;

#NG
&lt;%=# ---- cpro01\app\views\top\index.html.erb ---- %&gt;
</pre>
<h1>■NG時のエラーメッセージ</h1>
<p class="lang-name">Plain Text</p>
<pre class="brush: plain; auto-links: false;" style="margin:18px 0;">
 SyntaxError in Top#index

Showing app/views/top/index.html.erb where line #7 raised:

compile error
C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01/app/views/top/index.html.erb:7: syntax error, unexpected kENSURE, expecting &#039;)&#039;
C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01/app/views/top/index.html.erb:9: syntax error, unexpected kEND, expecting &#039;)&#039;

Extracted source (around line #7):

4: &lt;p&gt;Find me in app/views/top/index.html.erb&lt;/p&gt;
5: &lt;%= @gmap.div(:width =&gt; 550, :height =&gt; 400) %&gt;

Trace of template inclusion: app/views/top/index.html.erb

RAILS_ROOT: C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01
Application Trace | Framework Trace | Full Trace

C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01/app/views/top/index.html.erb:9:in `compile!&#039;

C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:61:in `compile&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:28:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/template.rb:199:in `render_template&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:260:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:343:in `_render_with_layout&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:257:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1246:in `render_for_file&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:941:in `render_without_benchmark&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in `realtime&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1322:in `default_render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1328:in `perform_action_without_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:in `call_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in `realtime&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:in `perform_action_without_flash&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:in `perform_action&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in `send&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in `process_without_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:in `process&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in `process&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:in `dispatch&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in `_call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:in `initialize&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:in `cache&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/session/cookie_store.rb:93:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service&#039;
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service&#039;
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:13:in `run&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:111
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#039;
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&#039;
script/server:3

C:/Documents and Settings/so-ten/My Documents/NetBeansProjects/cpro01/app/views/top/index.html.erb:9:in `compile!&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:61:in `compile&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/renderable.rb:28:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/template.rb:199:in `render_template&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:260:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:343:in `_render_with_layout&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_view/base.rb:257:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1246:in `render_for_file&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:941:in `render_without_benchmark&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in `realtime&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:51:in `render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1322:in `default_render&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:1328:in `perform_action_without_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:617:in `call_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:10:in `realtime&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/core_ext/benchmark.rb:17:in `ms&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/rescue.rb:160:in `perform_action_without_flash&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/flash.rb:146:in `perform_action&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in `send&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:527:in `process_without_filters&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/filters.rb:606:in `process&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:391:in `process&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/base.rb:386:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/routing/route_set.rb:434:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:88:in `dispatch&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:111:in `_call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:82:in `initialize&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:9:in `cache&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/query_cache.rb:28:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/params_parser.rb:15:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/session/cookie_store.rb:93:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/reloader.rb:29:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/failsafe.rb:26:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.3/lib/action_controller/dispatcher.rb:106:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/static.rb:31:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails/rack/log_tailer.rb:17:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service&#039;
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service&#039;
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start&#039;
C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:13:in `run&#039;
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/commands/server.rb:111
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require&#039;
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require&#039;
script/server:3

Request

Parameters:

None

Show session dump

--- 

Response

Headers:

{&quot;Content-Type&quot;=&gt;&quot;&quot;,
 &quot;Cache-Control&quot;=&gt;&quot;no-cache&quot;}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/erb%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ae%e3%82%b3%e3%83%a1%e3%83%b3%e3%83%88%e3%81%ab%e9%96%a2%e3%81%97%e3%81%a6-ca006.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>topページ表示用の初期ルーティング設定 &#8211; ca006</title>
		<link>http://www.zo-i.com/project004cpro01/top%e3%83%9a%e3%83%bc%e3%82%b8%e8%a1%a8%e7%a4%ba%e7%94%a8%e3%81%ae%e5%88%9d%e6%9c%9f%e3%83%ab%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0%e8%a8%ad%e5%ae%9a-ca006.html</link>
		<comments>http://www.zo-i.com/project004cpro01/top%e3%83%9a%e3%83%bc%e3%82%b8%e8%a1%a8%e7%a4%ba%e7%94%a8%e3%81%ae%e5%88%9d%e6%9c%9f%e3%83%ab%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0%e8%a8%ad%e5%ae%9a-ca006.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 02:16:41 +0000</pubDate>
		<dc:creator>zo-i</dc:creator>
				<category><![CDATA[Project004:cpro01]]></category>

		<guid isPermaLink="false">http://www.zo-i.com/?p=588</guid>
		<description><![CDATA[■index.htmlの削除
以下のファイルを削除
■routes.rb
▲39,46行目を追加
]]></description>
			<content:encoded><![CDATA[<h1>■index.htmlの削除</h1>
<p>以下のファイルを削除</p>
<p class="lang-name">Plain Text</p>
<pre class="brush: plain; auto-links: false;" style="margin:18px 0;">
cpro01/public/index.html
</pre>
<h1>■routes.rb</h1>
<p class="lang-name">Ruby</p>
<pre class="brush: ruby; auto-links: false;" style="margin:18px 0;">
# ---- cpro01\config\routes.rb ----

ActionController::Routing::Routes.draw do |map|
  map.resources :books

  # The priority is based upon order of creation: first created -&gt; highest priority.

  # Sample of regular route:
  #   map.connect &#039;products/:id&#039;, :controller =&gt; &#039;catalog&#039;, :action =&gt; &#039;view&#039;
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase &#039;products/:id/purchase&#039;, :controller =&gt; &#039;catalog&#039;, :action =&gt; &#039;purchase&#039;
  # This route can be invoked with purchase_url(:id =&gt; product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member =&gt; { :short =&gt; :get, :toggle =&gt; :post }, :collection =&gt; { :sold =&gt; :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many =&gt; [ :comments, :sales ], :has_one =&gt; :seller

  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection =&gt; { :recent =&gt; :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  # map.root :controller =&gt; &quot;welcome&quot;
  map.root :controller =&gt; &quot;top&quot;

  # See how all your routes lay out with &quot;rake routes&quot;

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing or commenting them out if you&#039;re using named routes and resources.
  map.connect &#039;:controller/:action.:format&#039;
  map.connect &#039;:controller/:action/:id&#039;
  map.connect &#039;:controller/:action/:id.:format&#039;
end
</pre>
<p>▲39,46行目を追加</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zo-i.com/project004cpro01/top%e3%83%9a%e3%83%bc%e3%82%b8%e8%a1%a8%e7%a4%ba%e7%94%a8%e3%81%ae%e5%88%9d%e6%9c%9f%e3%83%ab%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0%e8%a8%ad%e5%ae%9a-ca006.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

