This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/41

6月10〜11日の二日間にわたり開催された、日本Rubyカンファレンス2006(a.k.a. RubyKaigi2006)でRails In Productionというパネルディスカッションのパネラーとして参加させていただきました。

参加者の皆様、スピーカーの皆様、そして何より運営スタッフの皆様、 大変お疲れ様でした。大変楽しい時間がすごせました。ありがとうございます。

それから、僕がプレゼンで使用した資料はこちらになります:


rubykaigi06_takiuchi.ppt

会場が縦に長いスペースと聞いていたので、文字が見やすい高橋メソッドを使わせていただいたところ、スピーカー控え室で本家の高橋さんに添削&ご指導いただけるという幸運に恵まれました(笑) でかいプレゼンを買わなければ。

でかいプレゼン 高橋メソッドの本

それにしても、コメンテーター陣が凄かったですねー。むしろこっちから質問したかった(笑)  DHHさんから質問される、という状況はなかなか考えられないですよね。

2日間ほとんどスピーカー控え室の中におりましたが、Rubyコミュニティの著名な方々が沢山いらっしゃいまして、非常にエキサイティングでした。まつもとさん、DHHさん、西さん(くまくまーの人)ともはじめてお会いする事ができました。

特に、西さんとActiveRecord周りの話や、Patchを書くときに言葉の壁に苦しんでいる事など、いろいろな話が出来て良かったです。ぜひRails勉強会にもいらしてくださいね。Maihaのイラストを描いてくださってありがとうございました!

舞波乙です。

それから印象的だったのは、会場にいらっしゃっていた外国人の皆様は、Zevさん、ストヤンさんといい、なかなかご一緒していて楽しい方が多かった事です。海外で開催されているRubyConfも、こんな楽しい方々がいっぱいいらっしゃるんでしょうね。いつか参加してみたいです。 英語の壁を越えた暁には(いつになるやら…)

今後ともRubyコミュニティの発展をお祈りいたします。願わくは、来年のRuby会議で再会できますことを。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/41

posted by Png genki on Mon 12 Jun 2006 at 01:30

This article was migrated from http://rails.office.drecom.jp/hibi/archive/17

小生、栗東というところに住んでいるのでなかなか外の人(いや社内の人も)会う機会がないのだけど、この間たまたま出張で恵比寿のオフィスに行ったら、親睦会なる飲み会があってそれにまぜてもらえました。

そこに来られたのが、たたみラボの石橋さん。
http://iandeth.dyndns.org/mt/ian/


明るいお兄さんです。しかもリクルートなのになぜかwindowsロゴのTシャツ。


rubyしたことないです。やってみたいけど時間ない。。


普段はperl一色。


たたみラボは16畳くらいのほんとに畳の部屋にあるです。


たたみラボのPVを増やすために日夜励んでるです。


3人がごにょごにょ、3人がごにょごにょ、開発がごにょごにょ
といううそかほんとかわからないような話も聞けました。

こういう飲み会楽しいですねぇ。
栗東に住んでたらこんなことできないわぁ。

石橋さんー、こんばんわ。
この間はどうもです!楽しかったです♪
勝手に登場してもらっちゃいました、ゴメンナサイ。 http://rails.office.drecom.jp/hibi/archive/17

This article was migrated from http://rails.office.drecom.jp/hibi/archive/17

posted by Png satoko on Sun 11 Jun 2006 at 01:10

This article was migrated from http://rails.office.drecom.jp/hibi/archive/16

おととい見つけました。
前確かベータだったよね。多分。
しかもmassageうけてました、彼ら。
ガンマからどんな成長をとげるのか、楽しみです。

http://rails.office.drecom.jp/hibi/archive/16

This article was migrated from http://rails.office.drecom.jp/hibi/archive/16

posted by Png satoko on Sat 10 Jun 2006 at 01:20

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/39

render_componentの挙動を調査する必要があったので、メモを残しておきます。 render_componentは、いわゆるWidgetのような、再利用可能なGUI部品をレンダリングするメソッドです。以下に、要点だけ抜き出したソースを示します。

長いので先に結論だけ書いておくと、render_componentでレンダリングされるコンポーネントのコードから、呼び出し元の外部コントローラにアクセスするには、ActionController#parent_controllerを介せばOKです。

$ vim vendor/rails/actionpack/lib/action_controller/components.rb
module ActionController
module Components
  base.helper do
    def render_component(options)
      @controller.send(:render_component_as_string, options)
    end
  end
  module ClassMethods
    # Track parent controller to identify component requests
    def process_with_components(request, response, parent_controller = nil)
      controller = new
      controller.parent_controller = parent_controller
      controller.process(request, response)
    end
  end
  module InstanceMethods
    # Extracts the action_name from the request parameters and performs that action.
    def process_with_components(request, response, method = :perform_action, *arguments)
      flash.discard if component_request?
      process_without_components(request, response, method, *arguments)
    end
  protected
    # Returns the component response as a string
    def render_component_as_string(options)
      component_logging(options) do
        response = component_response(options, false)
        if redirected = response.redirected_to
          render_component_as_string(redirected)
        else
          response.body
        end
      end
    end
  private
    def component_response(options, reuse_response)
      klass    = component_class(options)
      request  = request_for_component(klass.controller_name, options)
      response = reuse_response ? @response : @response.dup
      klass.process_with_components(request, response, self)
    end
    # determine the controller class for the component request
    def component_class(options)
      if controller = options[:controller]
        controller.is_a?(Class) ?
          controller :
          "#{ controller.camelize }Controller".constantize
      else
        self.class
      end
    end
    # Create a new request object based on the current request.
    # The new request inherits the session from the current request,
    # bypassing any session options set for the component controller's class
    def request_for_component(controller_name, options)
      request         = @request.dup
      request.session = @request.session
      request.instance_variable_set(
        :@parameters,
        (options[:params] || {}).with_indifferent_access.update(
          "controller" => controller_name, "action" => options[:action],
          "id" => options[:id]))
      request
    end
  end
end

request_for_componentの中身:
with_indifferent_accessは、ActiveSupportによるHashの拡張機能で、Symbolと文字列のkeyを同一視できるようにするものです。instance_variable_setというのは、RubyのObjectクラスのメソッドで、こんな感じにインスタンス変数を外部から設定できてしまいます:

obj = Object.new
p obj.instance_variable_set("@foo", 1)  # => 1
p obj.instance_variable_set(:@foo, 2)   # => 2
p obj.instance_variable_get(:@foo)      # => 2

というわけで、上記のようにcontrolleractionidの指定を挿げ替えてrequestオブジェクトを偽装しているわけです。

そして、最終的にklass.process_with_components(request, response, self)が呼び出され、render_componentの呼び出し元のcontrollerparent_controllerに設定し、制御を実行しています。

したがって、レンダリングされるコンポーネントの内部からは、parent_controllerを介して呼び出し元のcontrollerとやり取りを行う事ができます。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/39

posted by Png genki on Wed 7 Jun 2006 at 01:37

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/38

ふつうのHaskell写経会に行ってきました。サイトはこの辺でしょうか?

12〜14人ぐらい集まって、淡々とペア写経をしました。SICPと比べるとだいぶテンポが速そうですね。3章の始めぐらいまで進みました。

ghci

Prelude> :t length
length :: [a] -> Int

のようにすると出てくる型変数(type variable)の[a], [b], ...というのが26個以上ある場合は枯渇しないんだろうか(ものすごくどうでも良いことなのですが、なんだかとても気になったのです)、という素朴な疑問に遭遇したので、角谷さんと一緒にちょっと調べたりしていました。

しかしよく考えると、この[a]とか[b]というのは、関数の型宣言時に人間がつけた記号をそのまま返しているだけのようなので、そんな心配はするまでも無かったようです。例えば;

foo :: [bar] -> [baz] -> [qux]

というような宣言をされていれば、ghci:tをしたときにはそのまま出てくるだけなんですね。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/38

posted by Png genki on Tue 6 Jun 2006 at 22:18

This article was migrated from http://rails.office.drecom.jp/hibi/archive/15

永久って書き方がすごいですが。

アプリを動かしてると、

"Illegal mix of collations
(latin1_swedish_ci,IMPLICIT) and
(sjis_japanese_ci,COERCIBLE) for operation '='"

みたいなエラーが出て。文字コードはUTF8とswedishなんたらだったけど。
したら、take another stepさんが対決してはった。
http://dream.ie.ariake-nct.ac.jp/~naoyuki/archives/000041.php

つまり、サーバとクライアントのコードが違うということらしいです。
ふむ。

mysqlのリファレンスを調べる。したらコレ。
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

SET NAMES 'x'

としたらいいらしい。
でもこれだとアプリで毎回しなくちゃいけないし。
大体rubyでどうするのかよくわからない。

そしたら!
先のmysqlのリファレンスのしたーーーのほうに
N Bernhardtさんがコメント。
--------------------------------------------------
Posted by N Bernhardt on August 17 2005 4:51pm

To change the connection charset permanently to UTF-8, add the following line in the [mysqld] section:
[mysqld]
init-connect='SET NAMES utf8'
--------------------------------------------------

で、/etc/mysql/my.cnfの[mysqld]のところにinit-…を追加しました。
show variables like 'character%';
show variables like 'collationr%';
してもやっぱり変数の値は変わってないですが、アプリを起動すると…
あら不思議!ちゃんと動きました!

(ただこれするとほかのアプリとかでUTF8にしたくないときも
UTF8になるので注意って書いてありました。なので注意です。)

とにかくやったーーー!
いやもうなんでも初心者で大変です。 http://rails.office.drecom.jp/hibi/archive/15

This article was migrated from http://rails.office.drecom.jp/hibi/archive/15

posted by Png satoko on Mon 5 Jun 2006 at 15:37

This article was migrated from http://rails.office.drecom.jp/hibi/archive/14

winのとよく似てます。

database.ymlのproductionのDB接続を編集

環境変数RAILS_ENVをセット。
export RAILS_ENV=production

script/aboutで確認
サービススタート!
lighttpd start -f lighttpd.myapp.conf -D

これでおっけー!
なんかあっけなかった。。。 http://rails.office.drecom.jp/hibi/archive/14

This article was migrated from http://rails.office.drecom.jp/hibi/archive/14

posted by Png satoko on Mon 5 Jun 2006 at 15:21

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/37

RailTies(RailsのCore)への PATCH5003が採用されました。

ちょっと嬉しいです。

これによって、./script/generate pluginuninstall.rb が生成されるので、その中にプラグインのUninstallコードを書けるようになります。

例えば、install.rbでCSSとかJavaScriptとか画像ファイルをpublic/以下にコピーするプラグインなどで、./script/plugin remove時にそれらを取り除くようにする事ができます。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/37

posted by Png genki on Sun 4 Jun 2006 at 15:11

This article was migrated from http://rails.office.drecom.jp/hibi/archive/13

すごいタイトルだね、これ。

winでproductionを試そうとしていたら、新井さんがVMWareを教えてくれた。
DebianもDBもRubyもいっぱい入ってお得なvmxももらう♪
なのでwinでproductionは頓挫。

ででlighttpd入ってなさそうなので、入れてみることにする。
--------------------------------------------------
参考:
http://wota.jp/ac/?date=20051113#p04
http://d.hatena.ne.jp/secondlife/20050406/1112719612
http://d.hatena.ne.jp/moro/20060130/1138628101
http://www.kharakawa.com/kh.log/archives/2006/01/lighttpd_fastcgi_rails.html
--------------------------------------------------
■lighttpdインストール
くまくまさんのを参考に。
/etc/apt/source.listに下記を追加
deb http://debian.bougyman.com unstable main

# aptitude update
# aptitude update
# aptitude install lighttpd
なんか途中でインストールするかといってくるけど、Yでリターン

■lighttpd.conf
でで、secondlifeさんのを参考に。
lighttpd.rails.confを作って起動するが、
RailsFCGIHanderが見つからないみたいなエラーが出るので 汗汗。
どうやら、dispatch.fcgiでrequire 'fcgi_handler'ができてないみたい。
でやとこさ、FCGIをインストールしてないことに気づく。

■FastCGIをインストール
kh.logさんのを参考に。
先に追加したsource.listのhttp://debian.bougyman.comの行を削除して、
aptitude update
aptitude instal libfcgi-ruby libfcgi-ruby1.8
で、これもインストールするかって聞いてくるのでYでリターン。

ちなみに、そこで紹介されてたlighttpdのURLではinstallできなかった。。。なんでかな。
URLが有効でなさそう。その辺が素人には大変です。

■Lighttpd開始・停止
下記で起動してエラーが出てないかみます。Ctrl+Cでstopできるみたい。
lighttpd start -f lighttpd.rails.conf -D

-Dつけないときはkill -term PIDで停止。

で、早速アクセス!
動いたーーーー!!!

でも一部動いてない。。。なんでだ。winでは動いてたのに。
エラーも出てなさそう。

明日はとりあえずproductioinをやろう。修正はその後だにゃ。
--------------------------------------------------
PS secondlifeさんが書かれていた、

次にpublic/dispatch.fcgiの二行目あたりに、
RAILS_ROOT = ENV['RAILS_ROOT']
を追加して


というくだりがあるのですが、これはなんで必要なのかなぁ。。。
よくわからないにゃ。
どなたか教えてくださいませませ。 http://rails.office.drecom.jp/hibi/archive/13

This article was migrated from http://rails.office.drecom.jp/hibi/archive/13

posted by Png satoko on Sun 4 Jun 2006 at 03:47

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/36

CentOSにEthnaを導入する手順をメモしておきます。

まず、CentOSにPHP5.1.4を導入します。 RPMを使う場合は「武蔵流プログラマへの道 - CentOSでPHP5のRPMを作ったよ。」が参考になりそうです。ソースから導入する場合は、僕が以前書いた記事も多少は参考になるかも。

PHPの導入が完了したら、こちらを参考に下記を実行します。

# pear install http://ethna.jp/pear/Ethna-2.1.0-preview1.tgz

次に、include_pathの通ったディレクトリに/usr/share/pear/Ethnaを移動します。

# cp -R /usr/share/pear/Ethna /usr/local/lib/php/Ethna

それから、いくつか依存ライブラリがあるので、無い場合は導入しましょう。

# pear install PEAR/DB
# pear channel-discover pearified.com
# pear install pearified/Smarty

これで完了です。非常に簡単ですね。

This article was migrated from http://rails.office.drecom.jp/takiuchi/archive/36

posted by Png genki on Thu 1 Jun 2006 at 18:09