Permalink
Browse files

Paginate admin store credits list

  • Loading branch information...
davidnorth committed Jan 3, 2012
1 parent 0c2588d commit b491e5aeef50d0b3065a1f4025b6a24e90705f42
Showing with 10 additions and 4 deletions.
  1. +7 −2 app/controllers/admin/store_credits_controller.rb
  2. +3 −2 app/views/admin/store_credits/index.html.erb
@@ -1,16 +1,21 @@
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)
flash[:error] = "Can't be edit, b/c already was used."
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
@@ -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 %>

0 comments on commit b491e5a

Please sign in to comment.