Ajax Paging在开发中工作但不在生产中(heroku) - Rails 3.1

时间:2011-12-17 12:58:00

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 heroku asset-pipeline

不知何故,ajax分页在我的Rails 3.1开发环境中工作,但在我将其部署到heroku时却没有。分页ID工作但没有ajax。

我知道这是很多代码。但我不想错过可能很重要的文件。

它可能与资产管道有关吗?

编辑:修正了它。不知何故,heroku在预编译我的资产方面遇到了问题。

客户控制人:

def index
  @title = "Customers"
  company = current_company
  @customers = company.customers.search(params[:search]).paginate(:page => params[:page], :order => 'lastname ASC')

  respond_to do |format| 
    format.html # index.html.erb 
    format.js # index.js.erb 
  end
end

索引视图文件:

<div id="customers"><%= render 'customers'%></div>

<% content_for :actionButtons do %>
<div class="pageHeader">
<div class="row">

<div class="span6">
<div class="action_links">
    <%= link_to t('buttons.newCustomer'), new_customer_path, :class => "btn primary" %>
</div>
</div>
<div class="span8">
<%= form_tag customers_path, :method => "get", :id => "customers_search" do %>
<fieldset>
<div class="clearfix">
    <div class="input">
        <%= text_field_tag(:search, params[:search], :placeholder=>"Search", :class => "inputText") %>
        <%= submit_tag t('buttons.search'), :name => nil, :class=>"btn primary" %>
    </div>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
<% end %>

_customers.html.erb:

<% if @customers.count == 0 %>

<h2>No customers found...</h2>

<% else %>

<div class="row">
<div class="span10">
<%= hidden_field_tag :direction, params[:direction] %>
<%= hidden_field_tag :sort, params[:sort] %>
<%= will_paginate(@customers, :renderer => HosperoListLinkRenderer)%>   &nbsp;
</div>
<div class="span5"> 
<div class="pagingInfos">
    <%= page_entries_info @customers %> 
</div>
</div>
</div>
<table class="bordered-table zebra-striped">
<tr>    
  <th>Name</th>
<th>Phone</th>
  <th></th>
<th></th>
<th></th>
</tr>

<% @customers.each do |customer| %>
<tr>     
  <td><%= customer.lastname %> <%= customer.firstname %></td>
<td><%= customer.phonenumber %></td>
  <td><%= link_to t('buttons.show'), customer, :class => "button" %></td>
  <td><%= link_to t('buttons.edit'), edit_customer_path(customer), :class => "button edit"  %></td>
  <td><%= link_to t('buttons.delete'), customer, confirm: 'Are you sure?', method: :delete, :class => "button delete"  %></td>
</tr>
<% end %>
</table>
<%= will_paginate(@customers, :renderer => HosperoListLinkRenderer)%> 

<% end %>

index.js.erb的:

$('#customers').html('<%= escape_javascript(render :partial => "customers") %>');

应用程序/资产/ Javascript角/ customers.js:

$(function() {
  $("#customers th a, #customers .pagination a").live("click", function() {
    $.getScript(this.href);
    return false;
  });
  $("#customers_search input").keyup(function() {
    $.get($("#customers_search").attr("action"), $("#customers_search").serialize(), null, "script");
    return false;
  });
});

1 个答案:

答案 0 :(得分:2)

由于您的代码看起来不错,我猜您的资产由于某种原因没有加载。他们没有编译,因此没有被提供,或者你没有正确加载它们。

相关问题