I have the following classes
class BusinessLocation
has_many :campaigns
end
My campaigns class as an attribute called event_return_rate. I am using meta_search's sort_link url helper to sort a list of Business_Locations using the following format:
<%= sort_link @search, :average_price, "Avg. Menu Price" %>
<%= sort_link @search, :temp_return_rate, "% of Sale" %>
In order to get the sorting to work, i had to c开发者_C百科reate a temp_return_rate attribute in my BusinessLocations to sort it using the sort_link helper. I would like to know if there is a way to do this without having to create a temp attribute in my BusinessLocations class.
Also since there are many campaigns associated with my BusinessLocation, when I need the query to return campaign who's end_date > Date.today (only one campaign will meet this criteria).
Thanks!
精彩评论