I have a model called Alpha, another model, Beta has foreign keys of alpha and gamma. I want to see if beta is present for a given alpha and gamma match, so I tried to do it for the alphabet named 'A' and a gamma named 'G' but it does not work because it For some reason to know the gamma for every beta, I know that I can put it in a dirty loop, but it seems very non-ROR.
a.betas.gamma.includes? (G) I also tried various forms of a.betas.find (: gamma => g) They also do not work, do I just accept to take everyone into the Beta model and make Beta class system? This is remarkably inconvenient.
If I think right:
class alpha < & Lt; ActiveRecord :: Base is - Medium: Betas End Class Beta & lt; & Lt; ActiveRecord :: Base is_to: alpha is_to: Gamma and Class Gamma & lt; & Lt; ActiveRecord :: Base is has_many: betas end Can you add : mam: gammas, through = & gt; : Beta for Alpha class? If so, try: a.gammas.exists? (G)
Comments
Post a Comment