当我尝试运行时,rake assets precompile
我收到此错误:Unexpected token: operator (>)
. 我发现这是因为 index.js.erb,因为将文件名更改为 .html.erb 使其可以编译。这是 index.js.erb 的内容:
$('#haikus').append('<%= j render(@haikus) %>');
<% if @haikus.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@haikus) %>');
<% else %>
$('.pagination').remove();
<% end %>
haikus.js.coffee:
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 200
$('.pagination').html('Loading...')
$.getScript(url)
$(window).scroll()
index.html.erb:
<div id="haikus">
<%= render @haikus %>
</div>
<div class="row pagination">
<div class="large-12 columns">
<%= will_paginate @haikus %>
</div>
</div>
如何修复它并使其编译?
谢谢!