#views/play/video_poker.html.erb <% @json[:cards].each { |card| %> <img src="<%image_url card.to_s+".jpg"%>" class="card"> <% } %> <input type="hidden" name="hash" value="<% @json[:hash]%>">
#controllers/play_controller.html.erb class PlayController < ApplicationController def video_poker cards = [] (0...5).each { cards.push Random.rand(1..53) } @json = { :cards => cards, :hash => SecureRandom.base64(12) } end end
上記のコードでviewに@jsonが渡されず、
<img src="" class="card"> <img src="" class="card"> <img src="" class="card"> <img src="" class="card"> <img src="" class="card"> <input type="hidden" name="hash" value="">
のようになってしまいます
どうしたらよいでしょうか
回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2014/10/21 17:35