ruby on rails - Conditional relation -


I've got a model like this:

  stem-id-ATC  

and then I have

  stemmelation-system_ id -related_stem_id -active  

I get the stems related to the following I can relate to

  class stem & lt; ActiviverCord :: Base is_mind: StamelLeation is_my: related_streams ,: through = & gt; : Stemmelling and Class Stamilation & Lt; ActiveRecord :: Base is_to: stem is_to: related_stem ,: class_name = & gt; "Stem" ,: foreign_key => "Related_stem_id" end  

But now I just want to get an active relationship.

I tried to add it to the stem model:

  has_many: active_related ,: through = & gt; : Stemrelations ,: Source = & gt; : Related_stem ,: conditions = & gt; {: Active = & gt; True}  

but it gives me an error because it tries to check the active flag on the stem model rather than stemrelation. What should I change here?

Thank you!

Are you making sure that you can be a conditional association name_scope fit here:

  class stem & lt; ActiviverCord :: Base is_mind: StamelLeation is_my: related_streams ,: through = & gt; : Stemrelations name_scope: active, conditions: & gt; {: Active = & gt; True} End  

You can use it like this:

  stem.first. Reloaded_system Active  

Comments