ruby on rails - Complex ActiveRecord association definition -
How do you map the dashed union using the ActiveCard? Is there any active record to do this? All I want is to get all unique available promotions for a particular item.
<
Use of Custom Finder
class items & lt; / P> ActiveRecord :: Base has_many: promotions,: finder_sql = & gt; "SELECT..FROM promotions..purchase_option_id IN (...)" end
Dirty and inactive but rummy way
My_item.purchase_options.map (& amp ;: Promotion).
Breaking the Shopping Option
Promotion
The HABT Association and items
& lt; -> Promoted Purchase Option
class items & lt; ActiveRecord :: Base is - Medium: promoted_purchase_options is _ many: promotions, via = & gt; I do not think it's a good idea to use designated scope
em> or new methods to define it would only will not work or perform queries unable to use them: items. Prior. Promotion count items. First. Publicity. Available Promotion.first.items.all
Perhaps it:
< Pre> class items & lt; ActiveRecord :: Base is _Maya: Purchase_Action is_mind: promotion, via = & gt; : Purchase_Options: UNIC = & gt; True end
Comments
Post a Comment