我创建简单的交易网站。在index.html.erb循环中只处理第一个循环时。但它show.html.erb工作Rails循环在javascript中失败
<h1>Listing Deal</h1><% @projs.each do |proj| %>
<%= proj.title %><br />
<% if Time.now < proj.end_date %>
<h3>Days Left:</h3> <div id="countdown" style="width:40%"> <%= distance_of_time_in_words(Time.now, proj.end_date) %> </div>
<% else %>
<h3> The Project period has passed! </h3>
<% end %>
<script type="text/javascript">
$(document).ready(function(){
$('#countdown').countdown({
"until" : new Date(<%= date_for_jquery_countdown(proj.end_date) %>)
});
})
</script><% end %>
Projs_helper.rb **
def date_for_jquery_countdown(date)
year = date.strftime('%Y')
month = date.strftime('%-m')
day = date.strftime('%d')
"#{year}, #{month}-1, #{day}"
end
的application.js
//= require jquery.plugin
//= require jquery.countdown
我的浏览器DIS玩index.html.erb只显示第一个工作,但别人不显示倒计时
我的模型DEF end_date之间 \t \t self.start_date + self.funding_period.days \t端 –