Try this
def show
@docs = Docs.where("id >", params[:id]).all
@docs.sort! { |a,b| a.id <=> b.id }
respond to do |format|
format.js
end
end
The primary problem MAY be that the adapter that you use to connect to your DB does not respect ordering
EDIT: Responding to your comment: Lets try moving the ordering to a view:
<% unless @docs.empty? %>
$("#published").append("<%=raw escape_javascript(render(@docs.sort! { |a,b| a.id <=> b.id })) %>");
<% end %>
EDIT2: PARTIALS
try rendering your partial like this
<%= render :partial => @outline.outline_docs, :collection => @docs.sort! { |a,b| a.id <=> b.id } %>
Alternatively (if you are sure the order is passed correctly in your existing code) just:
<%= render :partial => @outline.outline_docs, :collection => @docs %>
I didn't see how your outline is directly connected with @docs so you may try using :collections
with @docs (if the second render call is the culprit):
$("#published").append("<%=raw escape_javascript(render(:partial => "PARTIAL NAME", :collection => @docs)) %>");
<% end %>
Don't forget to replace PARTIAL NAME with whatever the partial you want to render @docs in or use @docs instead of PARTIAL NAME if you have corresponsing to_partial_path