Rails has_many with dinamyc :conditions

Posted by Fabiano PS on Stack Overflow See other posts from Stack Overflow or by Fabiano PS
Published on 2010-03-17T12:38:05Z Indexed on 2010/03/17 12:41 UTC
Read the original article Hit count: 536

Filed under:
|

Hello!

What I want is to create a Model that connects with other by a has_many in a dinamic way, without the foreing_key like this:

has_many :faixas_aliquotas, :class_name => 'Fiscal::FaixaAliquota',
            :conditions => ["regra_fiscal = ?", ( lambda { return self.regra_fiscal } ) ]

But I get the error:

: SELECT * FROM "fis_faixa_aliquota" WHERE ("fis_faixa_aliquota".situacao_fiscal_id = 1
AND (regra_fiscal = E'--- !ruby/object:Proc {}'))

Is my will makeable? I don't wanna black magic solution..

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about model