{"id":343,"date":"2016-12-08T20:28:39","date_gmt":"2016-12-08T11:28:39","guid":{"rendered":"http:\/\/okamurax.com\/?p=343"},"modified":"2017-01-09T05:34:29","modified_gmt":"2017-01-08T20:34:29","slug":"ubuntu%e3%81%b8%e3%81%aeruby%e3%80%81rails%e3%81%ae%e3%82%a4%e3%83%b3%e3%82%b9%e3%83%88%e3%83%bc%e3%83%ab","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=343","title":{"rendered":"Ubuntu\u3078\u306eRuby\u3001Rails\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb Rails\u306e\u4f7f\u3044\u65b9\u57fa\u672c"},"content":{"rendered":"<p>\u5fc5\u8981\u3067\u3042\u308c\u3070Passenger\u3082<br \/>\n<a href=\"http:\/\/okamurax.com\/?p=625\">Apache+Passenger\u3067Rails\u3092\u52d5\u304b\u3059<\/a><\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h2>\n<p><span style=\"color: #0000ff;\">sudo apt-get update<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo apt-get install ruby<br \/>\n<\/span><span style=\"color: #0000ff;\">ruby -v<br \/>\n<\/span><span style=\"color: #0000ff;\">gem -v (ruby\u306ever\u306b\u3088\u3063\u3066\u306fgem\u304c\u5165\u3089\u306a\u3044)<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo apt-get install ruby-dev zlib1g-dev liblzma-dev<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo gem install nokogiri<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo gem install rails<br \/>\n<\/span><span style=\"color: #0000ff;\">rails -v<\/span><\/p>\n<h2>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210<\/h2>\n<p>\u4ee5\u4e0b\u306f\u666e\u901a\u306e\u6d41\u308c\u3002<\/p>\n<p><span style=\"color: #0000ff;\">rails new xxx(\u3053\u3053\u3067xxx\u30d5\u30a9\u30eb\u30c0\u304c\u4f5c\u6210\u3055\u308c\u308b\u3002\u521d\u56de\u306e\u307fsqlite\u95a2\u9023\u306e\u30a8\u30e9\u30fc\u304c\u3067\u308b)<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo apt-get install sqlite3<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo apt-get install sqlite3 libsqlite3-dev<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo gem install sqlite3<br \/>\n<\/span><span style=\"color: #0000ff;\">sudo apt-get install nodejs<br \/>\n<\/span><span style=\"color: #0000ff;\">bundle install<br \/>\n<\/span><span style=\"color: #0000ff;\">rails s -b 0.0.0.0<\/span><\/p>\n<h2>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5f8c\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210<\/h2>\n<p>\u3053\u3053\u304b\u3089\u81ea\u5206\u7528<\/p>\n<p><span style=\"color: #0000ff;\">rails new xxx -B -C -T -d sqlite3<\/span><br \/>\nB\uff1abundle\u30b9\u30ad\u30c3\u30d7<br \/>\nC\uff1aActionCable\u95a2\u9023\u751f\u6210\u3057\u306a\u3044<br \/>\nT\uff1a\u30c6\u30b9\u30c8\u95a2\u9023\u751f\u6210\u3057\u306a\u3044<\/p>\n<p>\u3082\u3057\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u5225PC\u304b\u3089\u306e\u30b3\u30d4\u30fc\u3059\u308b\u5834\u5408\u3002\u30b3\u30d4\u30fc\u3057\u305f\u30d5\u30a9\u30eb\u30c0\u3067<br \/>\n<span style=\"color: #0000ff;\">bundle update<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:migrate<\/span><br \/>\n\u3092\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<h2>\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u8a2d\u5b9a<\/h2>\n<p><span style=\"color: #0000ff;\">\/config\/application.rb<\/span><br \/>\n\u306b<br \/>\n<span style=\"color: #0000ff;\">config.time_zone = &#8216;Tokyo&#8217;<\/span><br \/>\n\u3068\u8ffd\u52a0\u3002<\/p>\n<h2>Gemfile\u3092\u7de8\u96c6<\/h2>\n<p>\u3053\u3053\u3067\u306f<br \/>\n<span style=\"color: #0000ff;\">Coffee-rails<\/span><br \/>\n\u3092\u524a\u9664\u3057\u3001\u5fc5\u8981\u3067\u3042\u308c\u3070ruby\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3082\u6307\u5b9a\u3057\u3066\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3059\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">gem &#8216;bootstrap&#8217;<\/span><br \/>\n<span style=\"color: #0000ff;\">gem &#8216;tether-rails&#8217;<\/span><br \/>\n<span style=\"color: #0000ff;\">gem &#8216;font-awesome-sass&#8217;<\/span><br \/>\n\u3092\u8ffd\u52a0\u3057\u3001<br \/>\n<span style=\"color: #0000ff;\">bundle install<br \/>\n<span style=\"color: #333333;\">\u3092\u5b9f\u884c\u3002<\/span><\/span><\/p>\n<p>bundler\u306fgem\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u7ba1\u7406\u3092\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3001<br \/>\ngem\u306e\u4f9d\u5b58\u95a2\u4fc2\u304c\u66f8\u304b\u308c\u305fgemfile.lock\u3092\u751f\u6210\u3059\u308b\u3002<br \/>\n\u624b\u4f5c\u696d\u3067\u7de8\u96c6\u3059\u308b\u306e\u306fgemfile\u3067\u3001gemfile.lock\u306f\u3044\u3058\u3089\u306a\u3044\u3002<br \/>\ngemfile.lock\u306e\u3042\u308b\u5834\u6240\u3067bundle install\u3068\u3059\u308b\u3068\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u5fc5\u8981\u306agem\u304c\u5165\u308b\u3002<br \/>\nbundler\u304c\u8aad\u3093\u3067\u3044\u308b\u306e\u306flock\u306e\u307b\u3046\u3067\u3001<br \/>\nbundle update\u3092\u3059\u308b\u3068lock\u3092\u7121\u8996\u3057\u3001Gemfile\u3092\u5143\u306b\u30a4\u30f3\u30b9\u30c8\u3001lock\u306e\u518d\u751f\u6210\u3059\u308b\u3002<br \/>\nGemfile\u306e\u4e2d<br \/>\n&#8216;=&gt;1.3.0&#8217; \u306e\u8868\u8a18\u306f\u30011.3.0 \u4ee5\u4e0a\u3068\u3044\u3046\u610f\u5473<br \/>\n&#8216;~&gt;4.1.0&#8217; \u306e\u8868\u8a18\u306f\u30014.1.0 \u4ee5\u4e0a 4.2\u4ee5\u4e0b<\/p>\n<h2>generators.rb\u306e\u7de8\u96c6\uff08rails g\u30b3\u30de\u30f3\u30c9\u306e\u8a2d\u5b9a\uff09<\/h2>\n<p><span style=\"color: #0000ff;\">config\/initializers<\/span><br \/>\n\u306e\u4e2d\u306b<br \/>\n<span style=\"color: #0000ff;\">generators.rb<\/span><br \/>\n\u3092\u4f5c\u6210\u3057\u4ee5\u4e0b\u3092\u8a18\u8ff0\u3002<br \/>\n<span style=\"color: #0000ff;\">Rails.application.config.generators do |g|<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000g.helper false<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000g.assets false<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000g.skip_routes true<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000g.test_framework false<\/span><br \/>\n<span style=\"color: #0000ff;\">end<\/span><\/p>\n<h2>\u00a0css\u306e\u8a2d\u5b9a<\/h2>\n<p><span style=\"color: #0000ff;\">\/assets\/stylesheets\/application.css<\/span><br \/>\n\u3092scss\u306b\u5909\u66f4\u3057\u3066\u3001\u3055\u3089\u306b\u540c\u30d5\u30a9\u30eb\u30c0\u306bmain.scss\u3092\u4f5c\u6210\u3002<\/p>\n<p>application.scss\u306b\u306f\u3001\u4ee5\u4e0b\u3092\u8a18\u8ff0\u3002<br \/>\n<span style=\"color: #0000ff;\">@import &#8216;bootstrap&#8217;;<\/span><br \/>\n<span style=\"color: #0000ff;\">@import &#8216;font-awesome-sprockets&#8217;;<\/span><br \/>\n<span style=\"color: #0000ff;\">@import &#8216;font-awesome&#8217;;<\/span><br \/>\n<span style=\"color: #0000ff;\">@import &#8216;*&#8217;;<\/span><\/p>\n<h2>Javascript\u306e\u8a2d\u5b9a<\/h2>\n<p><span style=\"color: #0000ff;\">\/assets\/javascript\/application.js<\/span><br \/>\n\u306e\u4e2d\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18<br \/>\n<span style=\"color: #0000ff;\">\/\/= require tether<\/span><br \/>\n<span style=\"color: #0000ff;\">\/\/= require bootstrap-sprockets<\/span><\/p>\n<h2>\u30e2\u30c7\u30eb\u306e\u4f5c\u6210<\/h2>\n<p><span style=\"color: #0000ff;\">rails g model member<\/span><br \/>\n(\u5358\u6570\u5f62)<br \/>\n\u3053\u3053\u3067\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30af\u30b9\u30ea\u30d7\u30c8\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u540d\uff1a\u3000members<br \/>\n\u30af\u30e9\u30b9\u5b9a\u7fa9\uff1a\u3000Member<br \/>\n\u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\uff1a\u3000member.rb<br \/>\n\u30c6\u30b9\u30c8\uff1a\u3000member_test.rb<\/p>\n<p><span style=\"color: #0000ff;\">config\/routes.rb<\/span><br \/>\n\u306b<br \/>\n<span style=\"color: #0000ff;\">resources :members<br \/>\n<\/span>\u3068\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<h2><\/h2>\n<h2>\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30b9\u30af\u30ea\u30d7\u30c8\u8a2d\u5b9a<\/h2>\n<p>migrate\u30b9\u30af\u30ea\u30d7\u30c8\u306f\u30c6\u30fc\u30d6\u30eb\u3092\u5b9a\u7fa9\u3059\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">\/db\/migrate\/xxx<\/span><\/p>\n<p>\u53c2\u8003<br \/>\n<span style=\"color: #0000ff;\">http:\/\/railsdoc.com\/migration<\/span><\/p>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u95a2\u9023<\/h2>\n<p>rails new \u306e\u3068\u304d\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u7528\u306eyml\u304c\u81ea\u52d5\u3067\u4f5c\u6210\u3055\u308c\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">config\/database.yml<\/span><br \/>\n\u304c\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u4f5c\u6210\u30fb\u524a\u9664<\/h2>\n<p><span style=\"color: #0000ff;\">rake db:create<\/span><br \/>\n\u30c6\u30b9\u30c8\u3001\u958b\u767a\u7528\u304c\u3067\u304d\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">rake db:create RAILS_ENV=production<\/span><br \/>\n\u672c\u756a\u7528\u3060\u3051\u3067\u304d\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">rake db:dropb<\/span><br \/>\n\u30c6\u30b9\u30c8\u3001\u958b\u767a\u3092\u524a\u9664\u3067\u304d\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">rake db:dropb RAILS_ENV=production<\/span><br \/>\n\u672c\u756a\u7528\u3092\u524a\u9664\u3067\u304d\u308b\u3002<\/p>\n<h2>\u30c6\u30fc\u30d6\u30eb\u306e\u4f5c\u6210<\/h2>\n<p><span style=\"color: #0000ff;\">rake db:migrate<\/span><br \/>\n\u30c6\u30b9\u30c8\u3001\u958b\u767a\u7528<\/p>\n<p><span style=\"color: #0000ff;\">rake db:migrate RAILS_ENV=production<\/span><br \/>\n\u672c\u756a\u7528<\/p>\n<p>migrate\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u65bd\u3059\u308b\u3068schema.rb\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u5f8c\u5909\u66f4\u306e\u5834\u5408\u3001<br \/>\n<span style=\"color: #0000ff;\">rails g migration \u30af\u30e9\u30b9\u540d<br \/>\n<\/span>\u3067\u3067\u304d\u305f\u30d5\u30a1\u30a4\u30eb\u306badd_column\u7b49\u3092\u66f8\u3044\u3066\u518d\u5ea6db:migrate\u3067OK<\/p>\n<p>\u30c6\u30fc\u30d6\u30eb\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u623b\u3059\u5834\u5408<br \/>\n<span style=\"color: #0000ff;\">rake db:migrate VERSION=2015xxxx\uff08\u6570\u5b57\u306e\u90e8\u5206\u3060\u3051\uff09<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:rollbak(\u3072\u3068\u3064\u524d\u306e\u30d0\u30fc\u30b8\u30e7\u30f3)<\/span><\/p>\n<p>\u73fe\u5728\u306e\u30d0\u30fc\u30b8\u30e7\u30f3<br \/>\n<span style=\"color: #0000ff;\">rake db:migrate:status<\/span><\/p>\n<h2>\u30c6\u30fc\u30d6\u30eb\u306e\u7834\u68c4(\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u306e\u66f8\u304d\u76f4\u3057)<\/h2>\n<p><span style=\"color: #0000ff;\">rake db:migrate:reset<br \/>\n<span style=\"color: #333333;\">\u306f<\/span><br \/>\nrake db:drop<br \/>\nrake db:create<br \/>\nrake db:migrate<br \/>\n<span style=\"color: #333333;\">\u306e\uff13\u3064\u3068\u540c\u3058\u52b9\u679c\u304c\u3042\u308b\u3002<\/span><br \/>\n<\/span><\/p>\n<p>\u3061\u306a\u307f\u306b\u3001<br \/>\n<span style=\"color: #0000ff;\">rake db:reset<\/span><br \/>\n\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">rake db:drop<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:create<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:schema:load<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:seed<\/span><br \/>\n\u3068\u540c\u3058\u52b9\u679c\u304c\u3042\u308b\u3002<\/p>\n<p><span style=\"color: #0000ff;\">rake db:setup<\/span><br \/>\n\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">rake db:create<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:schema:load<\/span><br \/>\n<span style=\"color: #0000ff;\">rake db:seed<\/span><br \/>\n\u3068\u540c\u3058\u52b9\u679c\u304c\u3042\u308b\u3002<\/p>\n<h2>\u30b7\u30fc\u30c9\u30c7\u30fc\u30bf<\/h2>\n<p>\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u305f\u3068\u304d\u306bdb\/seeds.rb\u304c\u3067\u304d\u308b\u3002<br \/>\n\u4e2d\u306b\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u3044\u3066\u4ee5\u4e0b\u3092\u5b9f\u884c\u3002<\/p>\n<p><span style=\"color: #0000ff;\">i \u00a0= model_class.new<\/span><br \/>\n<span style=\"color: #0000ff;\">i.col_name = &#8220;xxx&#8221;<\/span><br \/>\n<span style=\"color: #0000ff;\">i.save!<\/span><br \/>\n\u3068\u3044\u3046\u306e\u304c\u57fa\u672c<\/p>\n<p><span style=\"color: #0000ff;\">rake db:seed<\/span><br \/>\n\u30c6\u30b9\u30c8\u3068\u958b\u767a<\/p>\n<p><span style=\"color: #0000ff;\">rake db:seed RAILS_ENV=production<\/span><br \/>\n\u672c\u756a<\/p>\n<p>\u3067\u30c7\u30fc\u30bf\u304c\u633f\u5165\u3055\u308c\u308b\u3002<\/p>\n<h2>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n<p><span style=\"color: #0000ff;\">root &#8220;control_name#action_name&#8221;<\/span><br \/>\n\u306f\u30eb\u30fc\u30c8\u30a2\u30af\u30bb\u30b9\u7528\u3002\u3053\u308c\u306f<br \/>\n<span style=\"color: #0000ff;\">:root<\/span><br \/>\n\u3067\u3053\u306e\u30d1\u30b9\u304c\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p>\u57fa\u672c\u306f<br \/>\n<span style=\"color: #0000ff;\">request_type path =&gt; &#8220;control_name#action_name&#8221;<\/span><\/p>\n<p>as: \u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u30b7\u30f3\u30dc\u30eb\u3067\u6307\u5b9a\u3067\u304d\u308b\u3002<\/p>\n<p>\u4f8b\uff11<\/p>\n<p><span style=\"color: #0000ff;\">routes.rb\uff1a\u3000<\/span><br \/>\n<span style=\"color: #0000ff;\">get &#8220;bad_request\/:a\/:b\/:c&#8221; =&gt; &#8220;top#bad_request&#8221;<\/span><\/p>\n<p><span style=\"color: #0000ff;\">top_controller.rb\uff1a<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u3000def bad_request<\/span><br \/>\n<span style=\"color: #0000ff;\">\u3000\u3000render :text =&gt; &#8220;hello world&#8221; + &#8221; &#8221; + params[:b] + &#8221; &#8221; + params[:a] + &#8221; &#8221; + params[:c]<\/span><br \/>\n<span style=\"color: #0000ff;\">end<\/span><\/p>\n<p>\u4ee5\u4e0b\u306e\u30a2\u30c9\u30ec\u30b9\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068<br \/>\n<span style=\"color: #0000ff;\">http:\/\/192.168.102.15\/app1\/bad_request\/taro\/Mr\/123<\/span><\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u306b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8868\u793a\u3055\u308c\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">hello world Mr taro 123<\/span><\/p>\n<p><span style=\"color: #0000ff;\">get &#8220;lesson\/:action(\/:name)&#8221; =&gt; &#8220;lesson&#8221;<\/span><br \/>\n\u306e\u3088\u3046\u306b\u30d1\u30e9\u30e1\u30fc\u30bf\u306b()\u3092\u4ed8\u3051\u308b\u3068\u7701\u7565\u53ef\u80fd\u3002<br \/>\n:action\u306b\u5165\u308b\u540d\u79f0\u304c\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u3001\u305d\u306e\u307e\u307e\u547c\u3070\u308c\u308b\u3002<\/p>\n<h2>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u306e\u4f5c\u6210<\/h2>\n<p><span style=\"color: #0000ff;\">rails g controller members<br \/>\n<\/span>\u30ea\u30bd\u30fc\u30b9\u7528\u306e\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u4f5c\u6210<br \/>\n\uff08CRUD\u306e\u3088\u3046\u306a\u96c6\u5408\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\u3092\u3059\u308b\u306e\u306f\u8907\u6570\u5f62\u3001\u305d\u308c\u4ee5\u5916\u306f\u5358\u6570\u5f62\uff09<\/p>\n<p>\u30af\u30e9\u30b9\u5b9a\u7fa9\uff1a\u3000MembersController<br \/>\n\u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\uff1a\u3000members_controller.rb<br \/>\n\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30d5\u30a9\u30eb\u30c0\uff1a\u3000app\/views\/members\/\u30a2\u30af\u30b7\u30e7\u30f3\u540d<br \/>\n\u30c6\u30b9\u30c8\uff1a\u3000members_controller_test.rb<\/p>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u3067\u306f\u4ee5\u4e0b\u3092\u5b9a\u7fa9\u3057\u3066\u3044\u304f\u3002<br \/>\n<span style=\"color: #0000ff;\">index \/members<\/span><br \/>\n<span style=\"color: #0000ff;\">new \/members\/123<\/span><br \/>\n<span style=\"color: #0000ff;\">create \/members\/new<\/span><br \/>\n<span style=\"color: #0000ff;\">show \/members\/123\/edit<\/span><br \/>\n<span style=\"color: #0000ff;\">edit \/members &#8211; POST<\/span><br \/>\n<span style=\"color: #0000ff;\">update \/members\/123 &#8211; PATCH<\/span><br \/>\n<span style=\"color: #0000ff;\">destroy \/members\/123 &#8211; DELETE<\/span><\/p>\n<p>rails g\u306e\u5909\u66f4\u3092\u3057\u3066\u3044\u306a\u3051\u308c\u3070\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u4f5c\u6210\u3068\u540c\u6642\u306b5\u500b\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u751f\u6210\u3055\u308c\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">controllers\/top_controller.rb<\/span><br \/>\n<span style=\"color: #0000ff;\">views\/top\/index.html.erb<\/span><br \/>\n<span style=\"color: #0000ff;\">helpers\/top_helper.rb<\/span><br \/>\n<span style=\"color: #0000ff;\">assets\/javascript\/top.js<\/span><br \/>\n<span style=\"color: #0000ff;\">assets\/stylesheets\/top.scss<\/span><\/p>\n<p>\u5909\u66f4\u3057\u305f\u3044\u5834\u5408\u306f\u3001generators.rb\u3092\u4fee\u6b63\u3059\u308b\u3002<\/p>\n<h2>\u30d3\u30e5\u30fc\u306e\u4f5c\u6210<\/h2>\n<p><span style=\"color: #0000ff;\">\/views\/controller_name\/method_name.html.erb<\/span><br \/>\n\u304c\u81ea\u52d5\u3067\u547c\u3070\u308c\u308b\u3002<\/p>\n<p>\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5b9a\u7fa9\u304c\u306a\u304f\u3066\u3082\u30d3\u30e5\u30fc\u306f\u547c\u3073\u51fa\u3055\u308c\u308b\u3002<\/p>\n<h2>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4f5c\u6210<\/h2>\n<p>\u5168\u4f53\u3092\u56f2\u3046\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u3001<br \/>\n<span style=\"color: #0000ff;\">views\/layouts<\/span><br \/>\n\u306b\u5165\u3063\u3066\u3044\u308b\u3002<br \/>\n<span style=\"color: #0000ff;\">application.html.erb<br \/>\n<\/span>\u30d3\u30e5\u30fc\u304c\u5165\u308b\u306e\u306f<br \/>\n<span style=\"color: #0000ff;\">&lt;% yield %&gt;<\/span><\/p>\n<p>\u305f\u3060\u3057\u3001<br \/>\n<span style=\"color: #0000ff;\">views\/layouts\/controller_name.html.erb<\/span><br \/>\n\u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u3001<br \/>\napplication.html.erb\u3088\u308a\u512a\u5148\u3057\u3066\u3001<br \/>\n\u4e0a\u8a18\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u8aad\u307e\u308c\u308b\u3002<\/p>\n<p>\u30a2\u30af\u30b7\u30e7\u30f3\u5185\u3067<br \/>\n<span style=\"color: #0000ff;\">render layout: false<\/span><br \/>\n\u3068\u3059\u308b\u3068\u3001\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u304c\u8aad\u307f\u8fbc\u307e\u308c\u306a\u3044\u3002<br \/>\n\u30d3\u30e5\u30fc\u306f\u8aad\u307e\u308c\u308b\u3002<br \/>\n\u30a2\u30af\u30b7\u30e7\u30f3\u5185\u3067\u3001<br \/>\n<span style=\"color: #0000ff;\">render :text =&gt; &#8220;xxx&#8221;<\/span><br \/>\n\u3068\u3059\u308b\u3068\u3001xxx\u3060\u3051\u3067\u30d3\u30e5\u30fc\u3082\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u3082\u547c\u3070\u308c\u306a\u3044\u3002<\/p>\n<h2>\u30d8\u30eb\u30d1\u30fc\u30e1\u30bd\u30c3\u30c9<\/h2>\n<p><span style=\"color: #0000ff;\">app\/helper<\/span><br \/>\n\u306e\u4e2d\u3067\u5b9a\u7fa9\u3059\u308b\u3002<\/p>\n<p>\u30d3\u30e5\u30fc\u306e\u4e2d\u3067\u81ea\u7531\u306b\u4f7f\u3048\u308b\u30e1\u30bd\u30c3\u30c9<\/p>\n<h2>\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3<\/h2>\n<p>\u30e2\u30c7\u30eb\u306e\u4e2d\u306b\u66f8\u304f\u3002\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058<br \/>\n<span style=\"color: #0000ff;\">validates :number,presence: true, length:{ \u30aa\u30d7\u30b7\u30e7\u30f3 }<\/span><\/p>\n<p>save\u304c\u547c\u3070\u308c\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u767b\u9332\u3057\u3088\u3046\u3068\u3057\u305f\u5024\u304c\u6b63\u3057\u3044\u304b\u30c1\u30a7\u30c3\u30af\u3002<\/p>\n<h2>\u30e2\u30c7\u30eb\u306e\u66f4\u65b0\u65b9\u6cd5<\/h2>\n<p>\u30e2\u30c7\u30eb\u306e\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9<\/p>\n<p>\u30d5\u30a1\u30a4\u30f3\u30c0\u30fc\u30e1\u30bd\u30c3\u30c9<br \/>\nfind\uff1a\u3000\u4e3b\u30ad\u30fc(id)\u3092\u6e21\u3059<br \/>\nfind_by\uff1a\u3000\u30ab\u30e9\u30e0\uff1a\u5024\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u6e21\u3059<br \/>\n\u7b49<\/p>\n<p>\u30af\u30a8\u30ea\u30e1\u30bd\u30c3\u30c9<br \/>\nwhere\uff1a\u3000\u30ab\u30e9\u30e0\uff1a\u5024\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u6e21\u3059<br \/>\nfind_by_sql\uff1a\u3000SQL\u3092\u6e21\u3059\u3002<br \/>\n\u7b49<\/p>\n<p>find\u306a\u3069\u30ec\u30b3\u30fc\u30c9\u3067\u53d6\u5f97\u3059\u308b\u306e\u304c\u30d5\u30a1\u30a4\u30f3\u30c0\u30fc\u30e1\u30bd\u30c3\u30c9\u3067\u3001\u30e2\u30c7\u30eb\u306b\u76f4\u63a5\u4f7f\u3046\uff08\u30af\u30e9\u30b9\u30e1\u30bd\u30c3\u30c9\uff09<br \/>\n\u30ec\u30b3\u30fc\u30c9\u306f\u30e2\u30c7\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u306a\u308b\u3002<\/p>\n<p>where\u306a\u3069\u306e\u30af\u30a8\u30ea\u30e1\u30bd\u30c3\u30c9\u3060\u3068\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u304c\u8fd4\u3063\u3066\u304f\u308b\u3002\u691c\u7d22\u6761\u4ef6\u3092\u4fdd\u6301\u3057\u3066\u3044\u308b\u3002<br \/>\n\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\u30d5\u30a1\u30a4\u30f3\u30c0\u30fc\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u308b\u3002<\/p>\n<h2>\u958b\u767a\u6642\u306e\u30e2\u30fc\u30c9<\/h2>\n<p>development\uff1a\u3000\u958b\u767a<br \/>\ntest\uff1a\u3000\u81ea\u52d5\u30c6\u30b9\u30c8\u7528<br \/>\nproduction\uff1a\u3000\u672c\u756a<\/p>\n<p>rails\u3084rake\u30b3\u30de\u30f3\u30c9\u306f\u5b9f\u884c\u6642\u306b<br \/>\n<span style=\"color: #0000ff;\">RAILS_ENV<\/span><br \/>\n\u306e\u4e2d\u306e\u74b0\u5883\u5909\u6570\u306b\u3088\u3063\u3066\u52d5\u4f5c\u304c\u5909\u308f\u3063\u3066\u304f\u308b\u3002<\/p>\n<p>\u30b3\u30fc\u30c9\u306e\u4e2d\u3067\u3082<br \/>\n<span style=\"color: #0000ff;\">Rails.env.development?<\/span><br \/>\n\u3084<br \/>\n<span style=\"color: #0000ff;\">Rails.env.production?<\/span><br \/>\n\u306a\u3069\u3067true\/false\u3067\u78ba\u8a8d\u3067\u304d\u308b\u3002<\/p>\n<h2><\/h2>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fc5\u8981\u3067\u3042\u308c\u3070Passenger\u3082 Apache+Passenger\u3067Rails\u3092\u52d5\u304b\u3059 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb sudo apt-get update sudo apt-get install ruby ruby -v gem &#8211; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=343\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Ubuntu\u3078\u306eRuby\u3001Rails\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb Rails\u306e\u4f7f\u3044\u65b9\u57fa\u672c&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-343","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343"}],"version-history":[{"count":30,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions"}],"predecessor-version":[{"id":701,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/343\/revisions\/701"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}