Added a named scope to make history lookups easier, Rate.history_for_user(user). #1915
This commit is contained in:
@@ -5,4 +5,12 @@ class Rate < ActiveRecord::Base
|
||||
|
||||
validates_presence_of :user_id
|
||||
validates_presence_of :date_in_effect
|
||||
|
||||
named_scope :history_for_user, lambda { |user|
|
||||
{
|
||||
:conditions => { :user_id => user.id },
|
||||
:order => 'date_in_effect DESC'
|
||||
}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h1>Rate History</h1>
|
||||
<%# TODO: Refactor out of the view once there is a hook in the controller (Post 0.8.0). %>
|
||||
<%# Can't expect everyone to upgrade at the moment %>
|
||||
<% @rates = Rate.find(:all, :conditions => { :user_id => @user.id }) %>
|
||||
<% @rates = Rate.history_for_user(@user) %>
|
||||
|
||||
<table class="list memberships">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user