开发者

Rails 3 Meta_Search Multi-level associations

开发者 https://www.devze.com 2023-03-19 11:38 出处:网络
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 lis

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消