CcEmailというテーブルがあり、そのカラムが以下のようになっています。
ruby
1 create_table "cc_emails", force: :cascade do |t| 2 t.integer "user_id", limit: 4 3 t.string "email1", limit: 255 4 t.string "email2", limit: 255 5 t.string "email3", limit: 255 6 t.string "email4", limit: 255 7 t.string "email5", limit: 255 8 t.string "email6", limit: 255 9 t.string "email7", limit: 255 10 t.string "email8", limit: 255 11 t.string "email9", limit: 255 12 t.string "email10", limit: 255 13 t.datetime "created_at", null: false 14 t.datetime "updated_at", null: false 15 end
このテーブルのemail1からemail10をイテレータで回して取得する方法を知りたいです。
ruby
1#index.html.erb 2 3<% (1..10).each do |n| %> 4 <p><%= CcEmail.last.email[xxx] %></p> 5<% end %>
この[xxx]の部分にnをどのような形でいれれば、email1 〜 email10を取得できるでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/02 05:14
2018/10/02 05:20
2018/10/02 05:58
2018/10/02 06:36