{"id":117,"date":"2014-01-18T00:09:22","date_gmt":"2014-01-17T15:09:22","guid":{"rendered":"http:\/\/lovelinux.mydns.jp\/?p=117"},"modified":"2014-04-01T13:23:47","modified_gmt":"2014-04-01T04:23:47","slug":"jqgrid%e3%81%a8ruby-on-rails%e3%81%a7%e3%82%a4%e3%83%b3%e3%82%bf%e3%83%a9%e3%82%af%e3%83%86%e3%82%a3%e3%83%96%e3%81%aacrud%e3%82%a2%e3%83%97%e3%83%aa%e3%82%b1%e3%83%bc%e3%82%b7%e3%83%a7%e3%83%b3","status":"publish","type":"post","link":"https:\/\/lovelinux.mydns.jp\/?p=117","title":{"rendered":"jqGrid\u3068Ruby on Rails4 \u3067\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306aCRUD\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u4f5c\u6210\uff08\u305d\u306e\uff11\uff09"},"content":{"rendered":"<h3>\u306f\u3058\u3081\u306b<\/h3>\n<p>Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001\u81ea\u52d5\u751f\u6210\u53ef\u80fd\u306a\u30da\u30fc\u30b8\u9077\u79fb\u578b\u306eCRUD\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u306a\u304f\u3001\u4e00\u65e6\u30da\u30fc\u30b8\u8868\u793a\u3057\u305f\u3089\u3001\u305d\u306e\u30da\u30fc\u30b8\u304b\u3089\u79fb\u52d5\u305b\u305a\u3001CRUD\u51e6\u7406\u3092\u3059\u3079\u3066\u5b8c\u4e86\u3057\u3066\u3057\u307e\u3046\u3088\u3046\u306a\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306aWeb\u30a2\u30d7\u30ea\uff08\u4fd7\u306b\u8a00\u3046SPA\uff09\u306e\u69cb\u7bc9\u65b9\u6cd5\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b jQuery\/jQuery\u306e\u30b0\u30ea\u30c3\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u3057\u3066\u30e1\u30b8\u30e3\u30fc\u306ajqGrid\u3092\u5229\u7528\u3057\u3001\u901a\u4fe1\u306fjQuery\u306eajax\u6a5f\u80fd\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306fRuby2.0\u3068Rails4.0\u306e\u69cb\u6210\u3068\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u8a18\u8f09\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306fgithub\u4e0a\u306e\u30d1\u30d6\u30ea\u30c3\u30af\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u516c\u958b\u3057\u307e\u3059\u306e\u3067\u3001\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u304a\u624b\u5143\u3067\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>Rails \u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u3001GitHub\u306bPush<\/h3>\n<p>\u4e8b\u524d\u6e96\u5099\u3068\u3057\u3066\u3001\u3054\u81ea\u8eab\u306eGitHub\u306b \u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3000\u30ea\u30dd\u30b8\u30c8\u30ea\u540d\uff1ajqgridrails\u3000\u3068\u3057\u3066\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>[bash]<br \/>\n$ rails new jqgridrails<\/p>\n<p>$ cd jqgridrails<br \/>\n$ git init<br \/>\n$ git add .<br \/>\n$ git commit -m &#8220;first commit&#8221;<br \/>\n$ git config user.name &#8220;\u767b\u9332\u3057\u305f\u3044\u540d\u524d&#8221;<br \/>\n$ git config user.email &#8220;\u767b\u9332\u3057\u305f\u3044Email&#8221;<\/p>\n<p>XXXXX\u3000\u306f github\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3067\u3059<br \/>\n$ git remote add origin https:\/\/XXXXX@github.com\/h-mito\/jqgridrails.git<br \/>\n$ git push -u origin master<\/p>\n<p>[\/bash]<\/p>\n<h3>Eclipse\u306bRails\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u308a\u8fbc\u3080<\/h3>\n<p>\u30d5\u30a1\u30a4\u30eb\uff1e\uff1e\u65b0\u898f\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8<\/p>\n<p>\u4e00\u822c\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u9078\u629e<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_004.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_004.png\" alt=\"\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 _004\" width=\"500\" class=\"alignnone size-medium wp-image-113\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_004.png 613w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_004-300x244.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><\/a><\/p>\n<p>\u65e2\u306b\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u540d\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u3068\u3059\u308b\u3002<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_005.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_005.png\" alt=\"\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 _005\" width=\"500\"  class=\"alignnone size-medium wp-image-114\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_005.png 613w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8-_005-300x244.png 300w\" sizes=\"(max-width: 613px) 100vw, 613px\" \/><\/a><\/p>\n<p>\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\uff1e\uff1e\u30d7\u30ed\u30d1\u30c6\u30a3\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30fb\u30cd\u30fc\u30c1\u30e3\u30fc<\/p>\n<p>Rails\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3002<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/jqgridrails-\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc-_006.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/jqgridrails-\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc-_006.png\" alt=\"jqgridrails \u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc _006\" width=\"500\" class=\"alignnone size-medium wp-image-115\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/jqgridrails-\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc-_006.png 777w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/jqgridrails-\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc-_006-300x211.png 300w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><\/p>\n<p>Rails\u30b5\u30fc\u30d0\u30fc\u4f5c\u6210<br \/>\n\u540d\u524d\uff1ajqgridrails<br \/>\n\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\uff1ajqgridrails<br \/>\nHost\/IP:127.0.0.1<br \/>\n\u30dd\u30fc\u30c8\uff1a3000<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/rails-server.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/rails-server.png\" alt=\"rails-server\" width=\"500\"  class=\"alignnone size-medium wp-image-119\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/rails-server.png 899w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/rails-server-300x154.png 300w\" sizes=\"(max-width: 899px) 100vw, 899px\" \/><\/a><\/p>\n<h3>Rails\u30b5\u30fc\u30d0\u30fc\u30c6\u30b9\u30c8\u8d77\u52d5<\/h3>\n<p>\u8d77\u52d5\u3059\u308b\u3068\u30a8\u30e9\u30fc<\/p>\n<p>[bash]<br \/>\ncd workspace\/jqgridrails<br \/>\ncp bin script -R<br \/>\n[\/bash]<\/p>\n<p>\u3042\u3089\u3081\u3066\u8d77\u52d5<br \/>\nhttp:\/\/localhost:3000 \u3067\u52d5\u4f5c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4e00\u65e6\u30b3\u30df\u30c3\u30c8\u3057\u3066\u3001Push\u3057\u3066\u304a\u304f<\/p>\n<p>[bash]<br \/>\n$ git add .<br \/>\n$ git commit -m &#8220;Eclipse Env create&#8221;<\/p>\n<p>$ git push<\/p>\n<p>[\/bash]<\/p>\n<h3>Section\u30de\u30b9\u30bf\u30fc\u3092\u4f5c\u308d\u3046\uff01<\/h3>\n<p>[bash]<br \/>\n$ git checkout -b Sectmast<br \/>\n[\/bash]<\/p>\n<p>eclipse \u3067database.yml\u3092\u3000\u81ea\u8eab\u306emysql\u74b0\u5883\u306b\u66f8\u304d\u63db\u3048\u308b\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u60c5\u5831\u306f\u30bb\u30ad\u30e5\u30a2\u306b\u6271\u3044\u305f\u3044\u306e\u3067\u3001.gitignore\u306bdatabase.yml\u3092\u8ffd\u8a18\u3002<\/p>\n<p>[bash]<br \/>\n$ nano .gitignore<br \/>\n\u6700\u7d42\u884c\u306b\u8ffd\u8a18<br \/>\nconfig\/database.yml<\/p>\n<p>$ git rm config\/database.yml &#8211;cached<\/p>\n<p>$ git add .<\/p>\n<p>$ git commit -m &#8220;Database Setting&#8221;<br \/>\n[\/bash]<\/p>\n<h3>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u308d\u3046<\/h3>\n<p>\u4e00\u822c\u7684\u306aCRUD\u3067\u306f\u306a\u304f\u3001Ajax\u3067SPA\u3092\u4f5c\u6210\u3059\u308b\u306e\u3067\u3001\u521d\u671f\u30da\u30fc\u30b8\u8868\u793a\u7528\u306eindex\u30e1\u30bd\u30c3\u30c9\u3068\u3001\u66f4\u65b0\u7528\u306eupdate\u30e1\u30bd\u30c3\u30c9\u306e\u307f\u6307\u5b9a<\/p>\n<p>[bash]<br \/>\n$ rails g controller sectmasts index update<br \/>\n[\/bash]<\/p>\n<h5>\u30e2\u30c7\u30eb\u3092\u4f5c\u308d\u3046\uff01<\/h3>\n<p>\u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u524d\u306b\u3001Rails\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3001sqlite\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001mysql\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3059\u308b\u3002\u307e\u305a\u306fGemfile\u306e &#8216;sqlite3&#8217;\u306e\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3001 &#8216;mysql2&#8217;\u306e\u884c\u3092\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<p>Gemfile\u306bmysql2\u3092\u8ffd\u8a18<\/p>\n<p>[ruby]<br \/>\n# Use sqlite3 as the database for Active Record<br \/>\n# gem &#8216;sqlite3&#8217;<\/p>\n<p># Use mysql as the database for Active Record<br \/>\ngem &#8216;mysql2&#8217;, &#8216;0.3.13&#8217;<br \/>\n[\/ruby]<\/p>\n<p>\u30e2\u30c7\u30eb sectmast\u306e\u81ea\u52d5\u751f\u6210<br \/>\n[bash]<br \/>\n$ rails g model sectmast<br \/>\n[\/bash]<\/p>\n<h3>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u3088\u3046<\/h3>\n<p>\u30e2\u30c7\u30eb\u306e\u4f5c\u6210\u6642\u306b\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u3068\u3044\u3046\u306e\u304c\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3055\u308c\u308b\u3002<br \/>\ndb\/migrate\u30d5\u30a9\u30eb\u30c0\u306b\u51fa\u6765\u305f migration\u30d5\u30a1\u30a4\u30eb\u3092\u4fee\u6b63\u3059\u308b\u3002<br \/>\n\u4fee\u6b63\u5185\u5bb9\u306f\u3000sectcd\/sectname\u306e\u8ffd\u52a0\u3002<\/p>\n<p>[ruby mark=&#8221;4,5&#8243;]<br \/>\nclass CreateSectmasts < ActiveRecord::Migration\n  def change\n    create_table :sectmasts do |t|\n      t.column :sectcd, \"varchar(2)\"\n      t.column :sectname, \"varchar(255)\"\n      t.timestamps\n    end\n  end\nend\n[\/ruby]\n\n\n\n\u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u5b9f\u884c\uff01\n[bash]\n$ rake db:migrate\n[\/bash]\n\n\n\n\n\n<h3>\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u3067\u5fc5\u8981\u306a\u3001JavaScript\u3001StyleSheet\u3092\u30b3\u30d4\u30fc<\/h3>\n<p>jquery \/ jquery UI \/ jqgrid\u3000\u95a2\u9023\u306eJavaScript\u3001StyleSheet\u3092\u30b3\u30d4\u30fc<br \/>\n\u30b3\u30d4\u30fc\u5148\u306f app\/assets\/javascripts &#038; app\/assets\/stylesheets<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/addJsStyle.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/addJsStyle.png\" alt=\"addJsStyle\" width=\"300\"  class=\"alignnone size-medium wp-image-116\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/addJsStyle.png 288w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/addJsStyle-127x300.png 127w\" sizes=\"(max-width: 288px) 100vw, 288px\" \/><\/a><\/p>\n<p>[bash]<br \/>\n$ git add .<br \/>\n$ git commit -m &#8220;create table and add jquery\/jqueryUI\/jqGrid Javascripts and StyleSheets&#8221;<br \/>\n[\/bash]<\/p>\n<h3>\u52d5\u4f5c\u78ba\u8a8d<\/h3>\n<p>\u3067\u306f\u3001\u4e00\u65e6\u52d5\u4f5c\u78ba\u8a8d<\/p>\n<p>Eclipse\u3088\u308a\u3001Rails\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u30d6\u30e9\u30a6\u30b6\u30fc\u3067 http:\/\/localhost:3000\/sectmasts\/index \u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7a7a\u3063\u307d\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_002.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_002.png\" alt=\"Jqgridrails - Chromium_002\" width=\"500\" class=\"alignnone size-medium wp-image-111\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_002.png 819w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_002-300x184.png 300w\" sizes=\"(max-width: 819px) 100vw, 819px\" \/><\/a><\/p>\n<h3>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u6295\u5165<\/h3>\n<p>[bash]<br \/>\n$ rails c<\/p>\n<p>> Sectmast.create :sectcd=>&#8221;01&#8243; ,:sectname => &#8220;market section&#8221;<br \/>\n   (0.3ms)  BEGIN<br \/>\n  SQL (0.5ms)  INSERT INTO `sectmasts` (`created_at`, `sectcd`, `sectname`, `updated_at`) VALUES (&#8216;2014-01-17 12:13:24&#8242;, &#8217;01&#8217;, &#8216;market section&#8217;, &#8216;2014-01-17 12:13:24&#8217;)<\/p>\n<p>> Sectmast.all<br \/>\n  Sectmast Load (0.6ms)  SELECT `sectmasts`.* FROM `sectmasts`<br \/>\n =><br \/>\n#&lt;ActiveRecord::Relation [#&lt;Sectmast id: 1, sectcd: &#8220;01&#8221;, sectname: &#8220;market section&#8221;, created_at: &#8220;2014-01-17 12:13:24&#8221;, updated_at: &#8220;2014-01-17 12:13:24&#8221;&gt;, #&lt;Sectmast id: 2, sectcd: &#8220;02&#8221;, sectname: &#8220;sales section&#8221;, created_at: &#8220;2014-01-17 12:13:42&#8221;, updated_at: &#8220;2014-01-17 12:13:42&#8221;&gt;, #&lt;Sectmast id: 3, sectcd: &#8220;03&#8221;, sectname: &#8220;development section&#8221;, created_at: &#8220;2014-01-17 12:13:54&#8221;, updated_at: &#8220;2014-01-17 12:13:54&#8221;&gt;]&gt;<br \/>\n[\/bash]<\/p>\n<h3>\u4e00\u89a7\u753b\u9762(HTML\uff09\u4f5c\u6210<\/h3>\n<p>view\/sectmasts\/index.html.erb<\/p>\n<p>\u5185\u5bb9\u306f\u4ee5\u4e0b<br \/>\n[html]<br \/>\n&lt;h1&gt;Sectmasts#index&lt;\/h1&gt;<\/p>\n<p>&lt;table id=&#8221;list&#8221;&gt;&lt;\/table&gt;<br \/>\n&lt;div id=&#8221;pager&#8221;&gt;&lt;\/div&gt;<br \/>\n[\/html]<\/p>\n<h3>\u30e1\u30a4\u30f3\u3068\u306a\u308bJavaScript\u4f5c\u6210<\/h3>\n<p>app\/assets\/javascripts\/sectmasts-main.js\u3092\u4f5c\u6210<\/p>\n<p>[javascript]<br \/>\njQuery(function($){<\/p>\n<p>\t$(&#8220;#list&#8221;).jqGrid({<br \/>\n\t   \turl:&#8217;\/sectmasts\/readForIndex&#8217;,<br \/>\n\t\tdatatype: &#8220;json&#8221;,<br \/>\n\t   \tcolNames:[&#8216;id&#8217;,&#8217;Section cd&#8217;, &#8216;Section Name&#8217;, &#8216;created&#8217;,&#8217;updated&#8217;],<br \/>\n\t   \tcolModel:[<br \/>\n\t   \t\t{name:&#8217;id&#8217;,index:&#8217;id&#8217;, width:55},<br \/>\n\t   \t\t{name:&#8217;sectcd&#8217;,index:&#8217;sectcd&#8217;, width:90},<br \/>\n\t   \t\t{name:&#8217;sectname&#8217;,index:&#8217;sectname&#8217;, width:200},<br \/>\n\t   \t\t{name:&#8217;created_at&#8217;,index:&#8217;created_at&#8217;, width:150},<br \/>\n\t   \t\t{name:&#8217;updated_at&#8217;,index:&#8217;updated_at&#8217;, width:150}<br \/>\n\t   \t],<br \/>\n\t   \trowNum:10,<br \/>\n\t   \trowList:[10,20,30],<br \/>\n\t   \tpager: &#8216;#pager&#8217;,<br \/>\n\t   \tsortname: &#8216;id&#8217;,<br \/>\n\t    viewrecords: true,<br \/>\n\t    sortorder: &#8220;asc&#8221;,<br \/>\n\t    caption:&#8221;Section master&#8221;<br \/>\n\t});<\/p>\n<p>\t$(&#8220;#list&#8221;).jqGrid(&#8216;navGrid&#8217;,&#8217;#pager&#8217;,{edit:false,add:false,del:false});\t<\/p>\n<p>});<\/p>\n<p>[\/javascript]<\/p>\n<h3>\u5168\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u30ed\u30b8\u30c3\u30af\u3092\u5b9f\u88c5(Ruby)<\/h3>\n<p>[ruby]<br \/>\n  def readForIndex<br \/>\n    response = {status:true}<\/p>\n<p>    recs = Sectmast.all<\/p>\n<p>    response[&#8220;rows&#8221;] = []<\/p>\n<p>    recs.each do |rec|<br \/>\n      response[&#8220;rows&#8221;].push(rec)<br \/>\n    end<br \/>\n    response[&#8220;page&#8221;] = 1<br \/>\n    response[&#8220;total&#8221;] = 1<br \/>\n    response[&#8220;records&#8221;] = recs.count<\/p>\n<p>    render :json => response<br \/>\n  end<br \/>\n[\/ruby]<\/p>\n<h3>\u4f5c\u6210\u3057\u305fRuby\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u5bfe\u5fdc\u3059\u308b\u30eb\u30fc\u30c8\u3092\u8ffd\u8a18<\/h3>\n<p>config\/routes.rb<\/p>\n<p>[ruby mark=&#8221;4&#8243;]<br \/>\nJqgridrails::Application.routes.draw do<br \/>\n  get &#8220;sectmasts\/index&#8221;<br \/>\n  get &#8220;sectmasts\/update&#8221;<br \/>\n  get &#8220;sectmasts\/readForIndex&#8221;<br \/>\n[\/ruby]<\/p>\n<h3>application.js\u306e\u8abf\u6574<\/h3>\n<p>jQuery\u306f\u81ea\u524d\u3067\u7528\u610f\u3057\u305f\u306e\u3067\u3001\u305d\u308c\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3002jquery_ujs \u306f\u3068\u308a\u3042\u3048\u305a\u3001\u5916\u3057\u3066\u304a\u304f\u3002<br \/>\n\u5909\u66f4\u90e8\u5206\u306e\u307f\u629c\u7c8b<\/p>\n<p>app\/assets\/javascripts\/application.js<\/p>\n<p>\u5909\u66f4\u524d<br \/>\n[javascript mark=&#8221;1,2&#8243;]<br \/>\n\/\/= require jquery<br \/>\n\/\/= require jquery_ujs<br \/>\n\/\/= require turbolinks<br \/>\n\/\/= require_tree .<br \/>\n[\/javascript]<\/p>\n<p>\u5909\u66f4\u5f8c<br \/>\n[javascript mark=&#8221;1&#8243;]<br \/>\n\/\/= require jquery-1.10.2<br \/>\n\/\/= require turbolinks<br \/>\n\/\/= require_tree .<br \/>\n[\/javascript]<\/p>\n<h3>\u52d5\u4f5c\u78ba\u8a8d\uff01\uff01<\/h3>\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b jqGrid\u306b\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u304c\u4e00\u89a7\u3055\u308c\u308c\u3070\u3001\u3081\u3067\u305f\u3057\u3081\u3067\u305f\u3057\u3002<br \/>\n\u307e\u3060\u307e\u3060\u3001\u3044\u3044\u52a0\u6e1b\u306a\u5b9f\u88c5\u3067\u3059\u306e\u3067\u3002\u6b21\u56de\u304b\u3089\u3082\u3046\u5c11\u3057\u307e\u3068\u3082\u306b\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><a href=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_003.png\"><img decoding=\"async\" src=\"http:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_003.png\" alt=\"Jqgridrails - Chromium_003\" width=\"500\" class=\"alignnone size-medium wp-image-112\" srcset=\"https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_003.png 819w, https:\/\/lovelinux.mydns.jp\/wp-content\/uploads\/2014\/01\/Jqgridrails-Chromium_003-300x184.png 300w\" sizes=\"(max-width: 819px) 100vw, 819px\" \/><\/a><\/p>\n<h3>github\u3078\u30d7\u30c3\u30b7\u30e5<\/h3>\n<p>\u3053\u306e\u30ea\u30bd\u30fc\u30b9\u306fPublic\u30ea\u30dd\u30b8\u30c8\u30ea\u3068\u3057\u3066\u516c\u958b\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u4ee5\u4e0b\u306eURL\u3067\u30bd\u30fc\u30b9\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<br \/>\n<a href=\"https:\/\/github.com\/h-mito\/jqgridrails.git\">https:\/\/github.com\/h-mito\/jqgridrails.git<\/a><\/p>\n<p>[bash]<br \/>\n$ git add .<br \/>\n$ git commit -m &#8220;Read Sectmasts Complete&#8221;<br \/>\n$ git checkout master<br \/>\n$ git merge Sectmast &#8211;no-ff<br \/>\n$ git push<br \/>\n[\/bash]<\/p>\n<p>\u6b21\u56de\u3078\u7d9a\u304f\u3002\u3002\u3002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3001\u81ea\u52d5\u751f\u6210\u53ef\u80fd\u306a\u30da\u30fc\u30b8\u9077\u79fb\u578b\u306eCRUD\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3067\u306f\u306a\u304f\u3001\u4e00\u65e6\u30da\u30fc\u30b8\u8868\u793a\u3057\u305f\u3089\u3001\u305d\u306e\u30da\u30fc\u30b8\u304b\u3089\u79fb\u52d5\u305b\u305a\u3001CRUD\u51e6\u7406\u3092\u3059\u3079\u3066\u5b8c\u4e86\u3057\u3066\u3057\u307e\u3046\u3088\u3046\u306a\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6\u306aWeb\u30a2\u30d7\u30ea\uff08\u4fd7\u306b\u8a00\u3046SPA\uff09\u306e\u69cb\u7bc9\u65b9\u6cd5\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u307e\u3059\u3002\u4eca\u56de\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306b jQuery\/jQuery\u306e\u30b0\u30ea\u30c3\u30c9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3068\u3057\u3066\u30e1\u30b8\u30e3\u30fc\u306ajqGrid\u3092\u5229\u7528\u3057\u3001\u901a\u4fe1\u306fjQuery\u306eajax\u6a5f\u80fd\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306fRuby2.0\u3068Rails4.0\u306e\u69cb\u6210\u3068\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u8a18\u8f09\u3057\u305f\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306fgithub\u4e0a\u306e\u30d1\u30d6\u30ea\u30c3\u30af\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u516c\u958b\u3057\u307e\u3059\u306e\u3067\u3001\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u3001\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u304a\u624b\u5143\u3067\u8a66\u3057\u3066\u307f\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002 Rails \u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u4f5c\u6210\u3001GitHub\u306bPush \u4e8b\u524d\u6e96\u5099\u3068\u3057\u3066\u3001\u3054\u81ea\u8eab\u306eGitHub\u306b \u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 \u4eca\u56de\u306f\u3000\u30ea\u30dd\u30b8\u30c8\u30ea\u540d\uff1ajqgridrails\u3000\u3068\u3057\u3066\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002 [bash] $ rails new jqgridrails $ cd jqgridrails $ git init $ git add . $ git commit -m &#8220;first commit&#8221; $ git config user.name &#8220;\u767b\u9332\u3057\u305f\u3044\u540d\u524d&#8221; $ git config user.email &#8220;\u767b\u9332\u3057\u305f\u3044Email&#8221; XXXXX\u3000\u306f github\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u3067\u3059 $ git remote add origin https:\/\/XXXXX@github.com\/h-mito\/jqgridrails.git $ git push -u origin master [\/bash] Eclipse\u306bRails\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u308a\u8fbc\u3080 \u30d5\u30a1\u30a4\u30eb\uff1e\uff1e\u65b0\u898f\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8 \u4e00\u822c\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u9078\u629e \u65e2\u306b\u30ed\u30fc\u30ab\u30eb\u306b\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u540d\u3092\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u3068\u3059\u308b\u3002 \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\uff1e\uff1e\u30d7\u30ed\u30d1\u30c6\u30a3\uff1e\uff1e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30fb\u30cd\u30fc\u30c1\u30e3\u30fc Rails\u306b\u30c1\u30a7\u30c3\u30af\u3092\u5165\u308c\u308b\u3002 Rails\u30b5\u30fc\u30d0\u30fc\u4f5c\u6210 \u540d\u524d\uff1ajqgridrails \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\uff1ajqgridrails Host\/IP:127.0.0.1 \u30dd\u30fc\u30c8\uff1a3000 Rails\u30b5\u30fc\u30d0\u30fc\u30c6\u30b9\u30c8\u8d77\u52d5 \u8d77\u52d5\u3059\u308b\u3068\u30a8\u30e9\u30fc [bash] cd workspace\/jqgridrails cp bin script -R [\/bash] \u3042\u3089\u3081\u3066\u8d77\u52d5 http:\/\/localhost:3000 \u3067\u52d5\u4f5c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002 \u4e00\u65e6\u30b3\u30df\u30c3\u30c8\u3057\u3066\u3001Push\u3057\u3066\u304a\u304f [bash] $ git add . $ git commit -m &#8220;Eclipse Env create&#8221; $ git push [\/bash] Section\u30de\u30b9\u30bf\u30fc\u3092\u4f5c\u308d\u3046\uff01 [bash] $ git checkout -b Sectmast [\/bash] eclipse \u3067database.yml\u3092\u3000\u81ea\u8eab\u306emysql\u74b0\u5883\u306b\u66f8\u304d\u63db\u3048\u308b\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u63a5\u7d9a\u60c5\u5831\u306f\u30bb\u30ad\u30e5\u30a2\u306b\u6271\u3044\u305f\u3044\u306e\u3067\u3001.gitignore\u306bdatabase.yml\u3092\u8ffd\u8a18\u3002 [bash] $ nano .gitignore \u6700\u7d42\u884c\u306b\u8ffd\u8a18 config\/database.yml $ git rm config\/database.yml &#8211;cached $ git add . $ git commit -m &#8220;Database Setting&#8221; [\/bash] \u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u3092\u4f5c\u308d\u3046 \u4e00\u822c\u7684\u306aCRUD\u3067\u306f\u306a\u304f\u3001Ajax\u3067SPA\u3092\u4f5c\u6210\u3059\u308b\u306e\u3067\u3001\u521d\u671f\u30da\u30fc\u30b8\u8868\u793a\u7528\u306eindex\u30e1\u30bd\u30c3\u30c9\u3068\u3001\u66f4\u65b0\u7528\u306eupdate\u30e1\u30bd\u30c3\u30c9\u306e\u307f\u6307\u5b9a [bash] $ rails g controller sectmasts index update [\/bash] \u30e2\u30c7\u30eb\u3092\u4f5c\u308d\u3046\uff01 \u30e2\u30c7\u30eb\u3092\u4f5c\u308b\u524d\u306b\u3001Rails\u3067\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3001sqlite\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001mysql\u3092\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u5909\u66f4\u3059\u308b\u3002\u307e\u305a\u306fGemfile\u306e &#8216;sqlite3&#8217;\u306e\u884c\u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3001 &#8216;mysql2&#8217;\u306e\u884c\u3092\u8ffd\u8a18\u3059\u308b\u3002 Gemfile\u306bmysql2\u3092\u8ffd\u8a18 [ruby] # Use sqlite3 as the database for Active Record # gem &#8216;sqlite3&#8217; # Use mysql as the database for Active Record gem &#8216;mysql2&#8217;, &#8216;0.3.13&#8217; [\/ruby] \u30e2\u30c7\u30eb sectmast\u306e\u81ea\u52d5\u751f\u6210 [bash] $ rails g model sectmast [\/bash] \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210\u3057\u3088\u3046 \u30e2\u30c7\u30eb\u306e\u4f5c\u6210\u6642\u306b\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u3068\u3044\u3046\u306e\u304c\u81ea\u52d5\u7684\u306b\u4f5c\u6210\u3055\u308c\u308b\u3002 db\/migrate\u30d5\u30a9\u30eb\u30c0\u306b\u51fa\u6765\u305f migration\u30d5\u30a1\u30a4\u30eb\u3092\u4fee\u6b63\u3059\u308b\u3002 \u4fee\u6b63\u5185\u5bb9\u306f\u3000sectcd\/sectname\u306e\u8ffd\u52a0\u3002 [ruby mark=&#8221;4,5&#8243;] class CreateSectmasts < ActiveRecord::Migration def change create_table :sectmasts do |t| t.column :sectcd, \"varchar(2)\" t.column :sectname, \"varchar(255)\" t.timestamps end end end [\/ruby] \u30c6\u30fc\u30d6\u30eb\u4f5c\u6210\u5b9f\u884c\uff01 [bash] $ rake db:migrate [\/bash] \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u30b5\u30a4\u30c9\u3067\u5fc5\u8981\u306a\u3001JavaScript\u3001StyleSheet\u3092\u30b3\u30d4\u30fc jquery \/ jquery UI \/ jqgrid\u3000\u95a2\u9023\u306eJavaScript\u3001StyleSheet\u3092\u30b3\u30d4\u30fc \u30b3\u30d4\u30fc\u5148\u306f app\/assets\/javascripts &#038; app\/assets\/stylesheets [bash] $ git add . $ git commit -m &#8220;create table and add jquery\/jqueryUI\/jqGrid Javascripts and StyleSheets&#8221; [\/bash] \u52d5\u4f5c\u78ba\u8a8d \u3067\u306f\u3001\u4e00\u65e6\u52d5\u4f5c\u78ba\u8a8d Eclipse\u3088\u308a\u3001Rails\u30b5\u30fc\u30d0\u30fc\u3092\u8d77\u52d5\u3057\u307e\u3059\u3002 \u30d6\u30e9\u30a6\u30b6\u30fc\u3067 http:\/\/localhost:3000\/sectmasts\/index \u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u7a7a\u3063\u307d\u306e\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308c\u3070OK\u3067\u3059\u3002 \u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u6295\u5165 [bash] $ rails c > Sectmast.create :sectcd=>&#8221;01&#8243; ,:sectname => &#8220;market section&#8221; (0.3ms) BEGIN SQL (0.5ms) INSERT INTO `sectmasts` (`created_at`, `sectcd`, `sectname`, `updated_at`) VALUES (&#8216;2014-01-17 12:13:24&#8242;, &#8217;01&#8217;, &#8216;market section&#8217;, &#8216;2014-01-17 12:13:24&#8217;) > Sectmast.all Sectmast Load (0.6ms) SELECT `sectmasts`.* FROM `sectmasts` => #&lt;ActiveRecord::Relation [#&lt;Sectmast id: 1, sectcd: &#8220;01&#8221;, sectname: &#8220;market section&#8221;, created_at: &#8220;2014-01-17 12:13:24&#8221;,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":400,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[7,6,2],"tags":[28,27,20,71],"class_list":{"0":"post-117","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-jquery","8":"category-rails","9":"category-2","10":"tag-javascript-2","11":"tag-jqgrid","12":"tag-jquery-2","13":"tag-rails"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=117"}],"version-history":[{"count":15,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions"}],"predecessor-version":[{"id":693,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions\/693"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=\/wp\/v2\/media\/400"}],"wp:attachment":[{"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lovelinux.mydns.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}