{"id":743,"date":"2007-06-17T01:00:00","date_gmt":"2007-06-16T16:00:00","guid":{"rendered":"https:\/\/ecoop.net\/memo\/2007-06-17-1.html"},"modified":"2026-08-10T14:41:31","modified_gmt":"2026-08-10T05:41:31","slug":"2007-06-17-1","status":"publish","type":"post","link":"https:\/\/www.ecoop.net\/memo\/archives\/2007-06-17-1.html","title":{"rendered":"Ruby on Rails \u306f\u3058\u3081\u306e\u4e00\u6b69"},"content":{"rendered":"<p>\n\u4eca\u66f4\u3067\u3059\u304c\u3001\u6700\u8fd1\u3088\u3046\u3084\u304f Rails \u3092\u89e6\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n&nbsp;<br \/>\n&#8211; 10\u5206\u3067\u4f5c\u308b Rails \u30a2\u30d7\u30ea for Windows<br \/>\n&#8211; Ruby on Rails \u516c\u5f0f &#8211; [<a href=\"http:\/\/www.rubyonrails.org\/\">http:\/\/www.rubyonrails.org\/<\/a>]<br \/>\n&nbsp;<br \/>\n10 \u5206\u3067\u3067\u304d\u308b Rails \u30a2\u30d7\u30ea\u306f\u3001\u672c\u5f53\u306b 10 \u5206\u3067 Ruby on Rails \u306e\u624b\u8efd\u3055\u304c\u5206\u304b\u308b\u306e\u3067\u304a\u52e7\u3081\u3067\u3059\u3002<br \/>\n10\u5206\u3067\u4f5c\u308b\u2026\u304c Windows + MySQL \u306a\u306e\u3067,\u3068\u308a\u3042\u3048\u305a FreeBSD \u3067 DB \u3092\u4f7f\u308f\u306a\u3044 Hello World \u3092\u8868\u793a\u3059\u308b\u5834\u5408\u306e\u30e1\u30e2\u3092\u6b8b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\n\u3042\u307e\u308a\u307e\u3068\u307e\u3063\u305f\u3082\u306e\u3067\u306f\u306a\u3044\u3067\u3059\u304c..<br \/>\n&nbsp;<\/p>\n<div class=\"readmore\">\n&nbsp;<br \/>\n1.Ruby + RubyGems \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<br \/>\n&nbsp;FreeBSD \u306e\u5834\u5408\u3001Ruby, RubyGems \u306e\u3044\u305a\u308c\u3082 ports \u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd\u3067\u3059(RubyGems \u306f lang\/ruby-extensions \u306b\u542b\u307e\u308c\u308b)\u3002<\/p>\n<blockquote><p># portinstall lang\/ruby lang\/ruby-extensions\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n2. RubyGems \u306e gem \u30b3\u30de\u30f3\u30c9\u3067 Ruby on Rails \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\n<\/p>\n<blockquote><p>$ gem install rails\n<\/p><\/blockquote>\n<p>\u4e0a\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4e00\u767a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3002\u4f9d\u5b58\u95a2\u4fc2\u306b\u3064\u3044\u3066\u805e\u304b\u308c\u308b\u306e\u304c\u5acc\u306a\u3089\n<\/p>\n<blockquote><p>$ gem install -y rails\n<\/p><\/blockquote>\n<p>\u3068\u3059\u308c\u3070\u30d7\u30ed\u30f3\u30d7\u30c8\u306a\u3057\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u308b\u306f\u305a\u3067\u3059\u3002<br \/>\n&nbsp;<br \/>\n3.$rails \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30b5\u30fc\u30d0\u306e\u69cb\u7bc9\n<\/p>\n<blockquote><p>$ rails foo \n<\/p><\/blockquote>\n<p>\u3053\u306e\u30b3\u30de\u30f3\u30c9\u3072\u3068\u3064\u3067\u3001\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4ee5\u4e0b\u306e\u3082\u306e\u3092\u3059\u3079\u3066\u3075\u304f\u3080\u30d5\u30a9\u30eb\u30c0 foo\/ \u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\n&#8211; \u7ba1\u7406\u7528\u30b9\u30af\u30ea\u30d7\u30c8(script\/)<br \/>\n&nbsp;&nbsp;\u305f\u3068\u3048\u3070 script\/server \u306f\u30b9\u30bf\u30f3\u30c9\u30a2\u30ed\u30f3\u30b5\u30fc\u30d0\u3067\u3042\u308a\u3001<br \/>\n&nbsp;&nbsp;script\/generate \u306f\u76ee\u7684\u306b\u5fdc\u3058\u305f\u30af\u30e9\u30b9\u3084\u30d5\u30a9\u30eb\u30c0\u306e\u81ea\u52d5\u751f\u6210\u3092\u884c\u3046\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<br \/>\n&#8211; \u516c\u958b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea(public\/)<br \/>\n&nbsp;&nbsp;\u5b9f\u969b\u306e URL \u30de\u30c3\u30d4\u30f3\u30b0\u306f public\/.htaccess \u304a\u3088\u3073\u3001public\/dispatches.cgi \u3067\u884c\u308f\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n&nbsp;&nbsp;rails \u30b5\u30fc\u30d0\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306f public\/index.html \u3067\u3059\u3002<br \/>\n&nbsp;&nbsp;<br \/>\n-\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u683c\u7d0d\u30d5\u30a9\u30eb\u30c0(app\/controllers)<br \/>\n&nbsp;&nbsp;MVC \u306e controller \u683c\u7d0d\u5148<br \/>\n&nbsp;&nbsp;\u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u6700\u521d\u304b\u3089\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u96db\u578b(app\/controllers\/Application.rb)\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n&nbsp;&nbsp;\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u4f5c\u6210\u6642\u306f\u30b3\u30de\u30f3\u30c9(scriot\/generate controller <\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u540d>) \u3067\u4f5c\u6210\u3059\u308b\u3068\u4fbf\u5229\u3067\u3059\u3002<br \/>\n&nbsp;<br \/>\n-\u30d3\u30e5\u30fc\u683c\u7d0d\u30d5\u30a9\u30eb\u30c0(app\/views)<br \/>\n&nbsp;&nbsp;MVC \u306e view \u683c\u7d0d\u5148\u3002<br \/>\n&nbsp;&nbsp;\u3053\u3053\u306b .rhtml (eRuby) \u5f62\u5f0f\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a1\u30a4\u30eb\u3067 view \u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<br \/>\n-\u30e2\u30c7\u30eb\u683c\u7d0d\u30d5\u30a9\u30eb\u30c0app\/models)<br \/>\n&nbsp;&nbsp;MVC \u306e model \u683c\u7d0d\u5148\u3002<br \/>\n&nbsp;&nbsp;script\/generate model <\u30e2\u30c7\u30eb\u30af\u30e9\u30b9\u540d> \u7b49\u3067\u4f5c\u6210\u3057\u305f\u30e2\u30c7\u30eb\u304c\u683c\u7d0d\u3055\u308c\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\n&#8211; \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb(config\/)\u3001<br \/>\n\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3068 URL \u306e\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u8a2d\u5b9a\u3059\u308b config\/routes.rb,<br \/>\n\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u4e0a\u306e\u3059\u3079\u3066\u306e Ruby \u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5f71\u97ff\u3059\u308b\u74b0\u5883\u8a2d\u5b9a\u3092\u884c\u3046 config\/environment.rb,<br \/>\nMySQL \u7b49\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u7528\u306e\u8a2d\u5b9a(\u30a2\u30ab\u30a6\u30f3\u30c8\u3001\u63a5\u7d9a\u5148 DB \u540d\u7b49)\u3092\u8a2d\u5b9a\u3059\u308b config\/database.yml \u7b49\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\n&#8211; \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u5229\u7528\u3059\u308b\u8ffd\u52a0 ruby \u30e9\u30a4\u30d6\u30e9\u30ea\u683c\u7d0d\u30d5\u30a9\u30eb\u30c0(lib\/)<br \/>\n&nbsp;&nbsp;\u3053\u3053\u306b\u3044\u308c\u3066\u304a\u304f\u3068 ruby \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306erequire \u3067\u30d1\u30b9\u6307\u5b9a\u306a\u3057\u3067\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n&nbsp;&nbsp;\u4f8b: lib\/my_library.rb \u304c\u3042\u308c\u3070\u3001rails \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304b\u3089\u306e\u53c2\u7167\u6642\u306f require &#8216;my_library&#8217; \u3068\u3059\u308b\u3060\u3051\u3067\u3088\u3044\u3002 <br \/>\n&nbsp;<br \/>\n4. \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u4f5c\u6210\n<\/p>\n<blockquote><p>script\/generate controller Foo\n<\/p><\/blockquote>\n<p>&nbsp;&nbsp;\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f HTTP \u30ea\u30af\u30a8\u30b9\u30c8 URL \u306e\u6700\u521d\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u8868\u8a18\u304c\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3001\u6b21\u304c\u547c\u3073\u51fa\u3059\u30e1\u30bd\u30c3\u30c9(action)\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\n&nbsp;&nbsp;\u305f\u3068\u3048\u3070 \n<\/p>\n<blockquote><p>http:\/\/localhost:3000\/foo\/edit\n<\/p><\/blockquote>\n<p>\u3078\u306e\u30a2\u30af\u30bb\u30b9\u306f\u3001\u30d5\u30a1\u30a4\u30eb app\/controllers\/foo_controller.rb \u306e\n<\/p>\n<blockquote><p>FooController#edit()\n<\/p><\/blockquote>\n<p>\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br \/>\n\u307e\u305f\u3001\n<\/p>\n<blockquote><p>http:\/\/localhost:3000\/foo\n<\/p><\/blockquote>\n<p>\u306e\u3088\u3046\u306b\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u7701\u7565\u3057\u305f\u5834\u5408\u306f\u3001Foo#index \u30e1\u30bd\u30c3\u30c9\u304c\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<br \/>\n\u4e00\u822c\u7684\u306a Web \u30b5\u30fc\u30d0\u306b\u304a\u3051\u308b index.html \u304c\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u306f index \u30e1\u30bd\u30c3\u30c9\u3068\u306a\u308b\u3068\u8003\u3048\u308c\u3070\u5206\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n5. Hello world \u3092\u51fa\u529b\u3059\u308b(view, model \u3092\u4f7f\u308f\u306a\u3044\u5834\u5408)<br \/>\nActionController::Base#render() \u3092\u4f7f\u3046\u306e\u304c\u57fa\u672c\u3067\u3059\u3002<br \/>\n\u5177\u4f53\u7684\u306b\u306f\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u5b9a\u7fa9\u30e1\u30bd\u30c3\u30c9(\u4f8b: FooController#index)\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\napp\/controllers\/foo_controller.rb\n<\/p>\n<blockquote><p># \u524d\u7565<br \/>\ndef index<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;render :text => &#8220;hello world!!&#8221;<br \/>\nend<br \/>\n# \u5f8c\u7565\n<\/p><\/blockquote>\n<p>&nbsp;<br \/>\n6.\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u30c6\u30ad\u30b9\u30c8\u306e\u51fa\u529b\u3092\u884c\u3046(view \u3092\u4f7f\u3046\u5834\u5408)<br \/>\n\u307e\u305a\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br \/>\napp\/views\/foo\/index.rhtml\n<\/p>\n<blockquote><p>&lt;html><br \/>\n&nbsp;&lt;head><br \/>\n&nbsp;&nbsp;&nbsp;&lt;title>Hello Example&lt;\/title><br \/>\n&nbsp;&lt;\/head><br \/>\n&nbsp;&lt;body><br \/>\n&nbsp;<%= @message %><br \/>\n&nbsp;&lt;\/body><br \/>\n&lt;\/html>\n<\/p><\/blockquote>\n<p>\u6b21\u306b\u3001\u3055\u304d\u307b\u3069\u306efoo_controller.rb \u306e def index \u3092\u6b21\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308c\u3070\u81ea\u52d5\u7684\u306b index.rhtml \u3092\u53c2\u7167\u3057\u307e\u3059\u3002\n<\/p>\n<blockquote><p>def index<br \/>\n&nbsp;&nbsp;&nbsp;@message = &#8220;Hello, world!&#8221;<br \/>\n&nbsp;&nbsp;&nbsp;render<br \/>\nend\n<\/p><\/blockquote>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001\u53c2\u7167\u3055\u308c\u308b view \u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306f\n<\/p>\n<blockquote><p>app\/<\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u540d>\/<\u30a2\u30af\u30b7\u30e7\u30f3\u540d>.rhtml\n<\/p><\/blockquote>\n<p>\u3067\u3059\u3002\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u66f4\u3067\u3059\u304c\u3001\u6700\u8fd1\u3088\u3046\u3084\u304f Rails \u3092\u89e6\u3063\u3066\u307f\u307e\u3057\u305f\u3002 &nbsp; &#8211; 10\u5206\u3067\u4f5c\u308b Rails \u30a2\u30d7\u30ea for Windows &#8211; Ruby on Rails \u516c\u5f0f &#8211; [htt &hellip; <a href=\"https:\/\/www.ecoop.net\/memo\/archives\/2007-06-17-1.html\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">Ruby on Rails \u306f\u3058\u3081\u306e\u4e00\u6b69<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[141],"tags":[15],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-lifehack","tag-ruby"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":4,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"predecessor-version":[{"id":1677,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/posts\/743\/revisions\/1677"}],"wp:attachment":[{"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecoop.net\/memo\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}