注: Rubyは2.1.0からSemantic Versioningを採用しています。 Ruby 2.1.1, 2.1.2等はバグ修正やセキュリティfixのみを含むため、リファレンスとしては2.1に統一しています。
セッションを使うCGIの簡単なサンプルを書いてみました。 CGI::Sessionを使って簡単に使えます。 データの格納先や形式をオプションでいろいろ変更できます。詳細はCGI::Sessionの解説を参照。 以下の例では、特にオプションは指定せずデフォルトで使ってます。 HTMLデータの出力は、CGI#outで行なうこと! 「puts "hoge"」とかしていると、クッキーの設定が出力されないため、セッションが有効になりません。(10分くらいはまった・・・。) #!/usr/bin/ruby -- require 'cgi' require 'cgi/session' cgi = CGI.new # セッションを作成 # デフォルトでは、一時ファイル領域のテキストファイルで記録されるらしい。 session = CGI::Session.new(cgi) if ( cgi["operat
・念のために古いバージョンも置いてあります。 旧バージョン ・RubyでCGIの書籍については、RubyによるCGIプログラミング 1. はじめに [2002-05-17] 1.1. このページを読むにあたって [2002-05-17] 1.2. CGIの準備 [2002-05-17] 1.3. Rubyの準備(UNIXでのインストール) [2002-05-17] 1.4. Rubyの準備(Windowsでのインストール) [2002-05-17] 2. まずは簡単な1行掲示板を作ろう! [2002-05-17] 2.1. print文を使おう [2002-05-17] 2.2. 変数を使おう [2002-05-17] 2.3. フォームのデータを受け取る [2002-05-17] 2.4. ファイルの読み出し [2002-05-17] 2.5. 配列 [2002-05-17] 2.6.
『るびま』は、Ruby に関する技術記事はもちろんのこと、Rubyist へのインタビューやエッセイ、その他をお届けするウェブ雑誌です。 Rubyist Magazine について 『Rubyist Magazine』、略して『るびま』は、日本 Ruby の会の有志による Rubyist の Rubyist による、Rubyist とそうでない人のためのウェブ雑誌です。 最新号 Rubyist Magazine 0058 号 バックナンバー Rubyist Magazine 0058 号 RubyKaigi 2018 直前特集号 Rubyist Magazine 0057 号 RubyKaigi 2017 直前特集号 Rubyist Magazine 0056 号 Rubyist Magazine 0055 号 Rubyist Magazine 0054 号 東京 Ruby 会議 11 直
Ruby/eRubyによるCGIプログラミング ゼータビッツ株式会社 前田 修吾 shugo@zetabits.co.jp Rubyというスクリプト言語をご存知でしょうか。数年 前まではまだ一部の人々にしか知られていなかったこ の言語が、現在急速に普及しつつあります。すでに いくつかの書籍が出版されていますし、雑誌などでも 取り上げられています。しかし、興味はあるけれども 実際に使ったことはないという方もまだ多いのではな いでしょうか。 そこで、本稿ではRubyの特長について簡単に説明した 上で、Ruby/eRubyによるCGIプログラミングについて 解説します。 Rubyとは? Rubyはまつもとゆきひろ氏によって設計・実装された スクリプト言語です。「オブジェクト指向スクリプト 言語」と紹介されることが多いように、本格的なオブ ジェクト指向機能を備えています。 ではRubyとは具体的に
statusとLocationヘッダを指定すればOK。 #!/usr/local/bin/ruby -- require "cgi" cgi = CGI.new print cgi.header( { "status" => "REDIRECT", "Location" => "http://d.hatena.ne.jp/unageanu/" }) cgiにアクセスすると以下が返され、 HTTP/1.1 302 Found Date: Sat, 12 Jul 2008 11:34:57 GMT Server: Apache/2.0.52 (CentOS) Location: http://d.hatena.ne.jp/unageanu/ Content-Length: 0 Connection: close Content-Type: text/html; charset=UTF-8ブラウ
最近、Rubyを勉強していて、いよいよRubyをサーバー上で動かそうかと思ったのですが、その方法を調べても情報が古いのがほとんどで、書いてあることを試しても出来ませんでした。mod_rubyを導入する方法や、RORを導入する方法はあったのですが、Rubyだけを動かす方法はありませんでした。自分の中では、Perlを動かすのと同じ要領で動かせると思ってたので、簡単に見つかるだろうと思ったのですが…。そこで、今後同じ思いをするだろう人のために私がした設定方法を示したいと思います。私の環境はWindows Vista Home Premium SP1ですが、Apacheの設定は共通だと思われるので、多くの場合、以下の設定で動くようになると思います。また、Vistaのセキュリティ関係の設定はOffにしておくと設定がやりやすいと思います(Program Files内をいじるので) 参考 http://
『るびま』は、Ruby に関する技術記事はもちろんのこと、Rubyist へのインタビューやエッセイ、その他をお届けするウェブ雑誌です。 Rubyist Magazine について 『Rubyist Magazine』、略して『るびま』は、日本 Ruby の会の有志による Rubyist の Rubyist による、Rubyist とそうでない人のためのウェブ雑誌です。 最新号 Rubyist Magazine 0058 号 バックナンバー Rubyist Magazine 0058 号 RubyKaigi 2018 直前特集号 Rubyist Magazine 0057 号 RubyKaigi 2017 直前特集号 Rubyist Magazine 0056 号 Rubyist Magazine 0055 号 Rubyist Magazine 0054 号 東京 Ruby 会議 11 直
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く