<?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>minor tranquilizer &#187; Ruby</title>
	<atom:link href="http://www.ookawara.com/archives/category/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ookawara.com</link>
	<description>イロ イッカイ ズツ・・・</description>
	<lastBuildDate>Sun, 29 Jan 2012 10:17:45 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ActiveScaffoldのAJAXフォーム上にあるコンボボックス2つを親子連携させる</title>
		<link>http://www.ookawara.com/archives/567</link>
		<comments>http://www.ookawara.com/archives/567#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:08:39 +0000</pubDate>
		<dc:creator>ookawara.com</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ActiveScaffold]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.ookawara.com/archives/567</guid>
		<description><![CDATA[　タイトルに書いたことを実現するのに、Railsだとobserve_fieldっていうのを使うと楽勝なんだけど、これがActiveScaffoldで動的ロードするFormにあるコンボボックスだと、AJAXでロードする情報 [...]]]></description>
			<content:encoded><![CDATA[<p>　タイトルに書いたことを実現するのに、Railsだとobserve_fieldっていうのを使うと楽勝なんだけど、これがActiveScaffoldで動的ロードするFormにあるコンボボックスだと、AJAXでロードする情報のなかにJavaScriptを書くことになってしまい動かないっていう罠。</p>
<p>　AJAXのレスポンスをinnerHTMLにぶち込んでごにょごにょとかそういう話もググれたんだけど、ActiveScaffoldだけにその辺自由度なく微妙。</p>
<p>　そこで苦肉の策として、Helperに「連動元コンボボックスのカラム名_form_column(record, field_name)」メソッドをオーバーライドしてSELECTタグを上書きしつつ、onchangeイベントでコンボボックスの中身をJavaScriptで強制書き換えするっていう何ともいえない香ばしい方法で対処する。</p>
<p>　<a href="http://wiki.github.com/activescaffold/active_scaffold/api-column">ActiveScaffoldのドキュメント</a>のそれっぽいところには「send_form_on_update_column」とかいかにもなメソッドがあるんだけど、悲しいかな 2.4以降に実装予定ということみたいだ。</p>
<p>　いやActiveScaffold超便利なんですけどね。用意された枠内でやってる分には。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ookawara.com/archives/567/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ISAPI_Rewrite</title>
		<link>http://www.ookawara.com/archives/562</link>
		<comments>http://www.ookawara.com/archives/562#comments</comments>
		<pubDate>Wed, 31 Mar 2010 13:31:34 +0000</pubDate>
		<dc:creator>ookawara.com</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ISAPI_Rewrite]]></category>
		<category><![CDATA[Mongrel]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://www.ookawara.com/archives/562</guid>
		<description><![CDATA[とあるシステムで、ISAPI_Rewriteなるものを使っている。 Ruby on Rails のアプリを開発して Mongrel で稼働させ、Windows Server (IIS6) 経由で呼び出そうというもの。 な [...]]]></description>
			<content:encoded><![CDATA[<p>とあるシステムで、ISAPI_Rewriteなるものを使っている。</p>
<p>Ruby on Rails のアプリを開発して Mongrel で稼働させ、Windows Server (IIS6) 経由で呼び出そうというもの。 <br/>なんでこんなことをやりたいかっていうと、IISでWindows統合認証を行い、認証済みのユーザだけがアプリを使え、かつWindows認証アカウントをアプリ側でもアカウントとして利用するという構成をとったため。</p>
<p>最初はIIS6 上で FastCGI を使って RoR を動かそうと思ったんだけど、なんか安定してなさそうなので、IIS を Proxy にしようと。（Apache使えよとかいうつっこみはいったん流して）</p>
<p>IISそのものには Proxy 機能は装備されていないのだが、IIS 用のアドインとして <a href="http://www.helicontech.com/isapi_rewrite/">ISAPI_Rewrite</a> というものが <a href="http://www.helicontech.com/">Helicon Tech</a> 社から提供されている。これはもともと Apache で言うところの mod_rewrite 相当のURL書き換え機能を提供するもの。</p>
<p>ISAPI_Rewrite には2種類のラインナップがあって、完全フリー版では Proxy はできないのだが、シェアウェア版（45日トライアル版あり。$99くらい）だと Proxy としても使える機能がある。</p>
<p>そこで今回はシェアウェア版を購入して、Proxy として使うことにした。</p>
<p>ダウンロード＆インストールは極めて簡単なので省略。 <br/>で、Mongrel が <a href="http://localhost:3000/">http://localhost:3000/</a> で動いており、これをIIS側の <a href="http://localhost/">http://localhost/</a> で受けてポート3000に流す。</p>
<p>設定はIISマネージャのWebサイトプロパティにISAPI_Rewrite設定タブがあるので、そこから設定エディタを開き「RewriteProxy /(.*) http\://localhost\:3000/$1 [A,I,U]」と記述。</p>
<p>文法は mod_proxy準拠（微妙に違うところもあるらしいが）。末尾の鍵括弧内はフラグだが、ここに「A」オプションをつけると、認証したユーザアカウント情報を httpヘッダに付加してくれる。たまにWWWで見かける Apache における方法と違うので、最初これが分からなくてあせった。 <br/>（落ち着いてドキュメントを読めばちゃんと書いてあったのだが）</p>
<p>あとライセンスキーの設定方法も最初分からなかったが、README を読んだら書いてあった。 <br/>インストール時に引数指定する、設定エディタに書く、の2種類があるようだ。</p>
<p>設定してみたが45日後にちゃんと効いているかちょっとドキドキする。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ookawara.com/archives/562/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WebARENA SuitePRO v2にRedmine(Ruby on Rails)を入れる</title>
		<link>http://www.ookawara.com/archives/382</link>
		<comments>http://www.ookawara.com/archives/382#comments</comments>
		<pubDate>Sun, 08 Feb 2009 00:47:06 +0000</pubDate>
		<dc:creator>ookawara.com</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Redmine]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.ookawara.com/?p=382</guid>
		<description><![CDATA[すでに導入しているSubversionと連携するチケット管理システムの導入を検討しておったのですが、Tracを試すも微妙に日本語化が大変だったりした割に連携部分でなんかトラブったため、目先を変えてRedmineを試そうと [...]]]></description>
			<content:encoded><![CDATA[<p>すでに導入している<a href="http://subversion.tigris.org/">Subversion</a>と連携するチケット管理システムの導入を検討しておったのですが、<a href="http://trac.edgewall.org/">Trac</a>を試すも微妙に日本語化が大変だったりした割に連携部分でなんかトラブったため、目先を変えて<a href="http://redmine.jp/">Redmine</a>を試そうと。</p>
<p><strong>１．とりあえず新しいRubyを入れとく</strong></p>
<p><code># wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz<br />
# tar xvfz ruby-1.8.7-p72.tar.gz<br />
# cd ruby-1.8.7-p72<br />
# ./configure<br />
# make<br />
# make install</code></p>
<p>WebARENAにもともと導入されているRuby（1.8.1）は/usr/binにいますが、新しいRubyは/usr/local/binにインストールされます。（場合によってはpathを張りなおしてbashリロードが必要かも）</p>
<p><strong>２．Rubygemsを入れる</strong></p>
<p><code># wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz<br />
# tar xvfz rubygems-1.3.1.tgz<br />
# cd rubygems-1.3.1<br />
# ruby setup.rb<br />
</code></p>
<p><strong>３．Ruby on Railsを入れる</strong></p>
<p>RedmineはRoR上で作られたアプリケーションです。</p>
<p><code># gem install rails --include-dependencies<br />
</code></p>
<p><strong>４．Redmine</strong></p>
<p><code># wget http://rubyforge.org/frs/download.php/49319/redmine-0.8.0.tar.gz<br />
# tar xvfz redmine-0.8.0.tar.gz<br />
# cd redmine-0.8.0/config<br />
# vi database.yml<br />
--------------------<br />
（追加）<br />
production:<br />
  adapter: sqlite3<br />
  dbfile: db/redmine.db<br />
--------------------<br />
# rake db:migrate RAILS_ENV=production<br />
(in /root/redmine-0.8.0)<br />
rake aborted!<br />
no such file to load -- openssl</p>
<p>(See full trace by running task with --trace)<br />
</code><br />
<strong>opensslがロードできませんエラーになっちゃいました。</strong></p>
<p><strong>５．RubyのOpenSSL拡張を確認する</strong></p>
<p><a href="http://d.hatena.ne.jp/hata-hata/20080416">http://d.hatena.ne.jp/hata-hata/20080416</a>を参考にさせていただきました。</p>
<p><code># cd ~/ruby-1.8.7-p72/ext/openssl<br />
# ruby extconf.rb<br />
=== OpenSSL for Ruby configurator ===<br />
=== Checking for system dependent stuff... ===<br />
checking for t_open() in -lnsl... no<br />
checking for socket() in -lsocket... no<br />
checking for assert.h... yes<br />
=== Checking for required stuff... ===<br />
checking for openssl/ssl.h... no<br />
=== Checking for required stuff failed. ===<br />
Makefile wasn't created. Fix the errors above.<br />
（ssl.hがないようなので、OpenSSLパッケージのバージョンを確認してソースコードをインストール）<br />
# rpm -qa | grep openssl<br />
openssl-0.9.7a-43.17.el4_7.2<br />
# yum install openssl-devel-0.9.7a-43.17.el4_7.2<br />
# ruby extconf.rb<br />
（Makefileが生成されればok）<br />
# make<br />
# make install<br />
# ruby -r openssl -e ""<br />
（何も表示されなければok）<br />
</code></p>
<p><strong>６．Redmine（再）</strong></p>
<p><code># cd ~/redmine-0.8.0/config<br />
# rake db:migrate RAILS_ENV=production<br />
# rake load_default_data RAILS_ENV=production<br />
（対話式でロケールをたずねてくるのでjaでこたえる）<br />
</code></p>
<p><strong>７．とりあえずRedmineを起動してみる</strong></p>
<p>RoRアプリに付属しているWebサーバWEBrickを使ってとりあえず動作確認をする。</p>
<p><code># cd ~/redmine-0.8.0<br />
# script/server -e production<br />
</code><br />
ポート3000にアクセスしてRedmineログインページが表示されればok</p>
<p><strong>８．RoRとapacheを連携させる</strong></p>
<p>Redmineをapacheで動かす設定。まずRoRをapache上で動かすためのモジュール、Phusion Passengerを入れる。</p>
<p><code># gem install passenger<br />
# passenger-install-apache2-module<br />
・・・<br />
Checking for required software...</p>
<p> * GNU C++ compiler... not found<br />
 * Ruby development headers... found<br />
 * OpenSSL support for Ruby... found<br />
 * RubyGems... found<br />
 * Rake... found at /usr/local/bin/rake<br />
 * Apache 2... found at /usr/sbin/httpd<br />
 * Apache 2 development headers... not found<br />
 * Apache Portable Runtime (APR) development headers... found<br />
 * Apache Portable Runtime Utility (APR) development headers... found<br />
 * fastthread... found<br />
 * rack... found</p>
<p>Some required software is not installed.<br />
But don't worry, this installer will tell you how to install them.</p>
<p>Press Enter to continue, or Ctrl-C to abort.<br />
・・・<br />
</code><strong>おっと今度はg++とapacheのソースコードがないと。<br />
</strong><br />
<code># yum install gcc-c++<br />
# yum install httpd-devel<br />
# passenger-install-apache2-module<br />
</code></p>
<p><strong>９．apacheの設定</strong></p>
<p>Phusion Passengerを入れた時にコンソールにhttpd.confの設定例を表示してくれるので、それを参考に適当に設定。公開するディレクトリのPermissonに注意ね。以上</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ookawara.com/archives/382/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- Quick Cache: failed to write cache. The cache/ directory is either non-existent ( and could not be created ) or it is not writable. -->
