2

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 create 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!

graywh
  • 9,640
  • 2
  • 29
  • 27
doug
  • 1,963
  • 2
  • 16
  • 24

0 Answers0