<?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/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>tech-memo &#187; rails</title>
	<atom:link href="http://tech.hapicky.com/archives/tag/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://tech.hapicky.com</link>
	<description>ソフトウェアエンジニアリングに関するメモ書き</description>
	<lastBuildDate>Tue, 02 Feb 2010 05:42:30 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/tag/rails/feed" />
		<item>
		<title>ルーティングのテスト</title>
		<link>http://tech.hapicky.com/archives/389</link>
		<comments>http://tech.hapicky.com/archives/389#comments</comments>
		<pubDate>Tue, 02 Feb 2010 05:42:30 +0000</pubDate>
		<dc:creator>hapicky</dc:creator>
				<category><![CDATA[今日のテストコード]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[テストコード]]></category>

		<guid isPermaLink="false">http://tech.hapicky.com/?p=389</guid>
		<description><![CDATA[railsのルーティングのテスト。 :id => /\d+/ と指定している部分「これじゃ部分一致では？」と思いましたが、ActionController::Routing::Route#generation_requirements で\Aと\Zで挟まれて再コンパイルされてますね。 config/routes.rb ?View Code RUBY1 2 3 4 5 6 ActionController::Routing::Routes.draw do &#124;map&#124; map.with_options&#40;:controller =&#62; 'products'&#41; do &#124;products&#124; products.connect 'products/:id', :action =&#62; 'show', :id =&#62; /\d+/ products.connect 'products', :action =&#62; 'create', :conditions =&#62; &#123; :method =&#62; :post &#125; end end spec/controllers/products_controller_spec.rb ?View Code RUBY1 2 3 4 5 6 7 [...]]]></description>
			<content:encoded><![CDATA[<p>railsのルーティングのテスト。<br />
<code>:id => /\d+/</code> と指定している部分「これじゃ部分一致では？」と思いましたが、ActionController::Routing::Route#generation_requirements で\Aと\Zで挟まれて再コンパイルされてますね。</p>
<p>config/routes.rb</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p389code3'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3893"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p389code3"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">ActionController::Routing::Routes</span>.<span style="color:#9900CC;">draw</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>map<span style="color:#006600; font-weight:bold;">|</span>
  map.<span style="color:#9900CC;">with_options</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:controller</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'products'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>products<span style="color:#006600; font-weight:bold;">|</span>
    products.<span style="color:#9900CC;">connect</span> <span style="color:#996600;">'products/:id'</span>, <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'show'</span>, <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>\d<span style="color:#006600; font-weight:bold;">+/</span>
    products.<span style="color:#9900CC;">connect</span> <span style="color:#996600;">'products'</span>, <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'create'</span>, <span style="color:#ff3333; font-weight:bold;">:conditions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:post</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>spec/controllers/products_controller_spec.rb</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p389code4'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3894"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
</pre></td><td class="code" id="p389code4"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec_helper'</span>
&nbsp;
describe ProductsController <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
  describe <span style="color:#996600;">'ルーティングのテスト'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
    it <span style="color:#996600;">'Products#show'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      params_from<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:get</span>, <span style="color:#996600;">'/products/123'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">should</span> == <span style="color:#006600; font-weight:bold;">&#123;</span> 
        <span style="color:#ff3333; font-weight:bold;">:controller</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'products'</span>,
        <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'show'</span>,
        <span style="color:#ff3333; font-weight:bold;">:id</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'123'</span>
      <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    it <span style="color:#996600;">'idが数字のみでない場合は404'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> 
        params_from<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:get</span>, <span style="color:#996600;">'/products/123abc'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">should</span> raise_error<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">ActionController::RoutingError</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    it <span style="color:#996600;">'Product#create'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      params_from<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:post</span>, <span style="color:#996600;">'/products'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">should</span> == <span style="color:#006600; font-weight:bold;">&#123;</span> 
        <span style="color:#ff3333; font-weight:bold;">:controller</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'products'</span>,
        <span style="color:#ff3333; font-weight:bold;">:action</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'create'</span>
      <span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    it <span style="color:#996600;">'createはPOSTのみ'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> 
        params_from<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:get</span>, <span style="color:#996600;">'/products'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">should</span> raise_error<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#6666ff; font-weight:bold;">ActionController::MethodNotAllowed</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>参考:</p>
<ul>
<li><a href="http://api.rubyonrails.org/classes/ActionController/Routing.html">Routing &#8211; Rails Framework  Documentation</a></li>
<li><a href="http://rspec.rubyforge.org/rspec-rails/1.3.2/classes/Spec/Rails/Example/RoutingHelpers.html">RoutingHelpers &#8211; RSpec Documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.hapicky.com/archives/389/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/389" />
	</item>
		<item>
		<title>Google Chart APIを使ってQRコードを生成する</title>
		<link>http://tech.hapicky.com/archives/353</link>
		<comments>http://tech.hapicky.com/archives/353#comments</comments>
		<pubDate>Thu, 28 Jan 2010 11:01:56 +0000</pubDate>
		<dc:creator>hapicky</dc:creator>
				<category><![CDATA[今日のテストコード]]></category>
		<category><![CDATA[GoogleChartAPI]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[テストコード]]></category>

		<guid isPermaLink="false">http://tech.hapicky.com/?p=353</guid>
		<description><![CDATA[QRコードの生成にGoogle Chart APIを使ってみました。 rspec-railsのhave_tagマッチャを使うときはassert_selectのドキュメントを見ながらの場合が多いですね。早く覚えてしまいたい。 app/helpers/chart_helper.rb ?View Code RUBY1 2 3 4 5 6 7 8 9 10 11 12 13 14 module ChartHelper &#160; def qr_code_tag&#40;text, options = &#123;&#125;&#41; param = &#123; :cht =&#62; 'qr', :chl =&#62; text &#125; param&#91;:chs&#93; = options.delete&#40;:chart_size&#41; &#124;&#124; '120x120' uri = URI::HTTP.build&#40;:host =&#62; 'chart.apis.google.com', :path =&#62; '/chart', :query =&#62; param.to_query&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>QRコードの生成にGoogle Chart APIを使ってみました。<br />
rspec-railsのhave_tagマッチャを使うときはassert_selectのドキュメントを見ながらの場合が多いですね。早く覚えてしまいたい。<br />
<img src="http://chart.apis.google.com/chart?chl=http%3A%2F%2Ftech.hapicky.com%2F&amp;chs=120x120&amp;cht=qr" alt="tech-memo" /><br />
app/helpers/chart_helper.rb</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p353code7'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3537"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p353code7"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> ChartHelper
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> qr_code_tag<span style="color:#006600; font-weight:bold;">&#40;</span>text, options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    param = <span style="color:#006600; font-weight:bold;">&#123;</span> 
      <span style="color:#ff3333; font-weight:bold;">:cht</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'qr'</span>,
      <span style="color:#ff3333; font-weight:bold;">:chl</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> text
    <span style="color:#006600; font-weight:bold;">&#125;</span>
    param<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:chs</span><span style="color:#006600; font-weight:bold;">&#93;</span> = options.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:chart_size</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'120x120'</span>
    uri = <span style="color:#CC00FF; font-weight:bold;"><span style="color:#6666ff; font-weight:bold;">URI::HTTP</span></span>.<span style="color:#9900CC;">build</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:host</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'chart.apis.google.com'</span>, <span style="color:#ff3333; font-weight:bold;">:path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/chart'</span>, <span style="color:#ff3333; font-weight:bold;">:query</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> param.<span style="color:#9900CC;">to_query</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    image_tag uri.<span style="color:#9900CC;">to_s</span>, options
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>spec/helpers/chart_helper_spec.rb</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p353code8'); return false;">View Code</a> RUBY</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3538"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p353code8"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'spec_helper'</span>
&nbsp;
describe ChartHelper <span style="color:#9966CC; font-weight:bold;">do</span>
&nbsp;
  it <span style="color:#996600;">'指定したテキストを含むQRコードを得られること'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    tag = helper.<span style="color:#9900CC;">qr_code_tag</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://tech.hapicky.com/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    expected_src = <span style="color:#996600;">'http://chart.apis.google.com/chart?chl=http%3A%2F%2Ftech.hapicky.com%2F&amp;amp;chs=120x120&amp;amp;cht=qr'</span>
    tag.<span style="color:#9900CC;">should</span> have_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'img[src=?]'</span>, expected_src<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  it <span style="color:#996600;">'サイズ指定できること'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    tag = helper.<span style="color:#9900CC;">qr_code_tag</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://tech.hapicky.com/'</span>, <span style="color:#ff3333; font-weight:bold;">:chart_size</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'300x300'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    expected_src = <span style="color:#996600;">'http://chart.apis.google.com/chart?chl=http%3A%2F%2Ftech.hapicky.com%2F&amp;amp;chs=300x300&amp;amp;cht=qr'</span>
    tag.<span style="color:#9900CC;">should</span> have_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'img[src=?]'</span>, expected_src<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  it <span style="color:#996600;">'altの指定ができること'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    tag = helper.<span style="color:#9900CC;">qr_code_tag</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://tech.hapicky.com/'</span>, <span style="color:#ff3333; font-weight:bold;">:alt</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'tech-memo'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    expected_src = <span style="color:#996600;">'http://chart.apis.google.com/chart?chl=http%3A%2F%2Ftech.hapicky.com%2F&amp;amp;chs=120x120&amp;amp;cht=qr'</span>
    tag.<span style="color:#9900CC;">should</span> have_tag<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'img[src=?][alt=tech-memo]'</span>, expected_src<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>参考:</p>
<ul>
<li><a href="http://rspec.rubyforge.org/rspec-rails/1.3.2/classes/Spec/Rails/Matchers.html#M000019">have_tag &#8211; RSpec Documentation</a></li>
<li><a href="http://api.rubyonrails.org/classes/ActionController/Assertions/SelectorAssertions.html#M000569">assert_select &#8211; Rails Framework Documentation</a></li>
<li><a href="http://code.google.com/intl/en/apis/chart/types.html#qrcodes">Google Chart API (QR Code)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tech.hapicky.com/archives/353/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/353" />
	</item>
		<item>
		<title>Passenger(mod_rails for Apache)を試す</title>
		<link>http://tech.hapicky.com/archives/19</link>
		<comments>http://tech.hapicky.com/archives/19#comments</comments>
		<pubDate>Mon, 14 Apr 2008 17:37:48 +0000</pubDate>
		<dc:creator>hapicky</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://tech.hapicky.com/archives/19</guid>
		<description><![CDATA[Passenger(mod_rails for Apache)をインストールしてみました。 試した環境は MaxOSX Tiger Apache2.2(MacPortsでインストール済み) です。 apacheが複数インストールされている場合は対象のApache apxsを指定する必要があるようです。 > export APXS2=/opt/local/apache2/bin/apxs まずgemでインストールして、 > sudo gem install passenger -y mod_railsをインストール。 > sudo passenger-install-apache2-module ありゃ。 ### In ext/apache2: g++ -flat_namespace -bundle -undefined dynamic_lookup Utils.o Logging.o Configuration.o Hooks.o mod_passenger.o -fPIC -o mod_passenger.so -lstdc++ -lpthread ../boost/src/libboost_thread.a -L/opt/local/lib -lapr-1 /usr/bin/ld: flag: -undefined dynamic_lookup can't be used with MACOSX_DEPLOYMENT_TARGET [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.modrails.com/" target="_blank">Passenger(mod_rails for Apache)</a>をインストールしてみました。<br />
試した環境は</p>
<ul>
<li>MaxOSX Tiger</li>
<li>Apache2.2(MacPortsでインストール済み)</li>
</ul>
<p>です。</p>
<p>apacheが複数インストールされている場合は対象のApache apxsを指定する必要があるようです。</p>
<pre class="brush:bash">
> export APXS2=/opt/local/apache2/bin/apxs
</pre>
<p>まずgemでインストールして、</p>
<pre class="brush:bash">
> sudo gem install passenger -y
</pre>
<p>mod_railsをインストール。</p>
<pre class="brush:bash">
> sudo passenger-install-apache2-module
</pre>
<p>ありゃ。</p>
<pre class="brush:plain">
### In ext/apache2:
g++ -flat_namespace -bundle -undefined dynamic_lookup Utils.o Logging.o Configuration.o Hooks.o mod_passenger.o -fPIC -o mod_passenger.so   -lstdc++ -lpthread ../boost/src/libboost_thread.a -L/opt/local/lib -lapr-1
/usr/bin/ld: flag: -undefined dynamic_lookup can't be used with MACOSX_DEPLOYMENT_TARGET environment variable set to: 10.1
collect2: ld returned 1 exit status
rake aborted!
Command failed with status (1): [g++ -flat_namespace -bundle -undefined dyn...]
/opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/rakefile:132
(See full trace by running task with --trace)
</pre>
<p>明らかに怪しいので MACOSX_DEPLOYMENT_TARGET を設定してリトライ。</p>
<pre class="brush:bash">
> export MACOSX_DEPLOYMENT_TARGET=10.4
> sudo passenger-install-apache2-module
</pre>
<p>とおった。</p>
<pre class="brush:plain">
The Apache 2 module was successfully installed.
</pre>
<p>以下のように表示されるので、httpd.confに設定を追加。</p>
<pre class="brush:plain">
Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so
RailsSpawnServer /opt/local/lib/ruby/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server
RailsRuby /opt/local/bin/ruby
</pre>
<p>VirtualHostの設定でrailsアプリケーションの位置を指定。</p>
<pre class="brush:plain">
&lt;VirtualHost *:80&gt;
        ServerName test.hoge.com
        DocumentRoot /path/to/rails/public
&lt;/VirtualHost&gt;
</pre>
<p>apacheを再起動。</p>
<pre class="brush:bash">
> apachectl configtest
> sudo apachectl restart
</pre>
<p>無事動作しました。<br />
<a href="http://blog.masuidrive.jp/index.php/2008/04/14/mod_rails_uses_triple_memory_than_mongrel/" target="_blank">mod_rails(passenger)はmogrelの3倍メモリを食う？</a> らしいですが、どちらを使おうか。</p>
<p>ちなみにapacheを再起動することなく、railsアプリケーションを再読み込みしたい場合はrailsアプリのtmpディレクトリに restart.txt を置けば（または更新すれば）よいとのこと。ふむ。<br />
<a href="http://www.modrails.com/documentation/Users%20guide.html#_redeploying_restarting_the_ruby_on_rails_application" target="_blank">Passenger users guide</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tech.hapicky.com/archives/19/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/19" />
	</item>
		<item>
		<title>retrospectivaが動かなくなる</title>
		<link>http://tech.hapicky.com/archives/14</link>
		<comments>http://tech.hapicky.com/archives/14#comments</comments>
		<pubDate>Thu, 31 Jan 2008 16:01:16 +0000</pubDate>
		<dc:creator>hapicky</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[retrospectiva]]></category>

		<guid isPermaLink="false">http://www.hapicky.com/tech-memo/?p=14</guid>
		<description><![CDATA[retrospectivaというプロジェクト管理ツールをちょこっと使っているのですが、ある日開いてみるとエラーでアクセスできない。 最近railsをupdateしていたことが原因と判明。対策をとりました。 config/environment.rbを参照してみると、 Retrospectiva depends on RubyOnRails version 1.2.x. との記載が。さらにRAILS_GEM_VERSIONの設定が見当たらない。 同ファイルに指示がありますが、freezeタスクを実行してrailsのバージョンを固定します。 retrospectivaのルートディレクトリに移動して、 > rake rails:freeze:edge TAG=rel_1-2-6 でOK。（svn使っているようですね。） 無事動くようになりました。]]></description>
			<content:encoded><![CDATA[<p><a href="http://retrospectiva.org/">retrospectiva</a>というプロジェクト管理ツールをちょこっと使っているのですが、ある日開いてみるとエラーでアクセスできない。<br />
最近railsをupdateしていたことが原因と判明。対策をとりました。</p>
<p>config/environment.rbを参照してみると、</p>
<blockquote><p>Retrospectiva depends on RubyOnRails version 1.2.x.</p></blockquote>
<p>との記載が。さらにRAILS_GEM_VERSIONの設定が見当たらない。<br />
同ファイルに指示がありますが、freezeタスクを実行してrailsのバージョンを固定します。</p>
<p>retrospectivaのルートディレクトリに移動して、</p>
<pre>> rake rails:freeze:edge TAG=rel_1-2-6</pre>
<p>でOK。（svn使っているようですね。）</p>
<p>無事動くようになりました。</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.hapicky.com/archives/14/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/14" />
	</item>
		<item>
		<title>railsアプリのルートURLをhttp://domain/hoge/のようにする。</title>
		<link>http://tech.hapicky.com/archives/4</link>
		<comments>http://tech.hapicky.com/archives/4#comments</comments>
		<pubDate>Fri, 04 Jan 2008 05:19:08 +0000</pubDate>
		<dc:creator>hapicky</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">/tech-memo/?p=4</guid>
		<description><![CDATA[rails、mongrel、apache、mod_proxyで、ルートURLをhttp://domain/hoge/のようにする方法。 1.railsアプリをmongrelで起動する。 &#62; mongrel_rails start -p 3000 --prefix /hoge ※prefixオプションをつける。 2.apacheのhttpd.confにmod_proxyの設定を追加する。 LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so ProxyPass /hoge http://localhost:3000/hoge ProxyPassReverse /hoge http://localhost:3000/hoge 3.apacheを再起動する。]]></description>
			<content:encoded><![CDATA[<p>rails、mongrel、apache、mod_proxyで、ルートURLをhttp://domain/hoge/のようにする方法。</p>
<p>1.railsアプリをmongrelで起動する。</p>
<pre>
&gt; mongrel_rails start -p 3000 --prefix /hoge</pre>
<p>※prefixオプションをつける。</p>
<p>2.apacheのhttpd.confにmod_proxyの設定を追加する。</p>
<pre>
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyPass /hoge http://localhost:3000/hoge
ProxyPassReverse /hoge http://localhost:3000/hoge</pre>
<p>3.apacheを再起動する。</p>
]]></content:encoded>
			<wfw:commentRss>http://tech.hapicky.com/archives/4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://tech.hapicky.com/archives/4" />
	</item>
	</channel>
</rss>

