アウトプットができる技術者に

it's a time to take a new step !

カラムを追加してみる

Summary
How To
  • vimgrepで「subscription」フィールドを探して、その下に「author」を追加する作業を繰り返す
 :vimgrep subscription ./**/*.* | cw
  • 該当は下記5ファイル
models/post.rb|4 col 10| field :subscription, type: String
./views/posts/_form.html.erb|19 col 18| <%= f.label :subscription %><br />
./views/posts/_form.html.erb|20 col 22| <%= f.text_area :subscription %>
./views/posts/index.html.erb|15 col 18| <td><%= post.subscription %></td>
./views/posts/show.html.erb|10 col 13| <%= @post.subscription %>
動作確認
  • すでにブラウザから確認・登録可能。
  • migrationは必要ない。スゲー楽。。

MongoDBを直接確認
  • 前回のを残したかったので、今回はmongo_test2で作ったので、DB名が少し変わってます
mongo
use mongo_test2_development
show collections
db.posts.find()
  • authorが増えていることを確認。
{ "_id" : ObjectId("517a998916435269f6000001"), "title" : "abc", "subscription" : "abcd" }
{ "_id" : ObjectId("517a9c1d164352d63f000002"), "title" : "adcol", "subscription" : "adcol", "author" : "author1" }