Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Paginate admin store credits list

  • Loading branch information...
commit b491e5aeef50d0b3065a1f4025b6a24e90705f42 1 parent 0c2588d
@davidnorth davidnorth authored
View
9 app/controllers/admin/store_credits_controller.rb
@@ -1,7 +1,7 @@
class Admin::StoreCreditsController < Admin::ResourceController
before_filter :check_amounts, :only => [:edit, :update]
prepend_before_filter :set_remaining_amount, :only => [:create, :update]
-
+
private
def check_amounts
if (@store_credit.remaining_amount < @store_credit.amount)
@@ -9,8 +9,13 @@ def check_amounts
redirect_to admin_store_credits_path
end
end
-
+
def set_remaining_amount
params[:store_credit][:remaining_amount] = params[:store_credit][:amount]
end
+
+ def collection
+ super.page(params[:page])
+ end
+
end
View
5 app/views/admin/store_credits/index.html.erb
@@ -14,7 +14,7 @@
<tbody>
<% @store_credits.each do |store_credit|%>
<tr id="<%= dom_id store_credit %>">
- <td><%= link_to store_credit.user.email, admin_user_url(store_credit.user) %></td>
+ <td><%= link_to store_credit.user.email, admin_user_url(store_credit.user) if store_credit.user.present? %></td>
<td><%= number_to_currency store_credit.amount %></td>
<td><%= number_to_currency store_credit.remaining_amount %></td>
<td><%= store_credit.reason %></td>
@@ -24,7 +24,7 @@
<%= link_to_edit store_credit %> &nbsp;
<% else %>
<%= t(:was_partially_used) %>
- <% end %>
+ <% end %>
<%= link_to_delete store_credit %>
<% else %>
<%= t(:was_fully_used) %>
@@ -37,3 +37,4 @@
</tbody>
</table>
+<%= paginate @store_credits %>
Please sign in to comment.
Something went wrong with that request. Please try again.