Saturday, 15 January 2011

ruby - relation has_many rails with inheritance -


I have:

  class character & lt; ActiveRecord :: Base is: Medium: Item, By: character_items has_many: character_item end class item & lt; ActiveRecord :: Base Class Weapons & lt; Item class armor & lt; Item   

I have to implant:

myCharacter.weapons

is_maya: via weapon, :: character_items Not working, I want the same thing as the item, but only to get the "weapon" items I want to filter with the "Type" column.

Thx for help

PS: I am on Rail 4

is_many: via weapon, :: character_items, terms: {character_items: {type: "weapon"}}, class_name: "item", source :: item

Hope

Answers from the matrix: Helps answer:

  is_maya: arms, {Via: character_ts, source :: items}, - & gt; {Where (type: 'weapon')}    

No comments:

Post a Comment