Somehow ajax paging is working in my Rails 3.1 development environment but not when i deploy it to heroku. The paging id working but without ajax.
I know that’s a lot of code. But i prefer not to miss out files which might be important.
Could it have something to do with the assets pipeline?
EDIT: Fixed it. Somehow heroku had problems precompiling my assets.
Customer controller:
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
The index view file:
<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)%>
</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") %>');
app/assets/javascripts/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;
});
});
As your code looks OK, I would guess that your assets aren’t loading for some reason. Either they haven’t compiled and thus aren’t being served, or your not loading them correctly.