Forum: Ruby on Rails Problems with Rails and Postgres

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Rafael R. (Guest)
on 2009-04-16 21:10
Hi all,

i have a method that I use in the 'after_save' that is implemented as
follows:


 def verify
    a =11674
    x =  self.aui_codigo


      reinc =AutoInfracao.find_by_sql("select age((select aui_data_lav
from tb_aui_auto_infracao where aui_codigo=#{a}),
(select max(aui_data_lav)from tb_aui_auto_infracao where aui_codigo
in(select a.aui_codigo from tb_aur_auto_inf_regular a,tb_iau_itens_auto
i where a.for_cod =(select for_cod from tb_aur_auto_inf_regular where
aui_codigo=#{a}) and a.lir_codigo=(select lir_codigo from
tb_aur_auto_inf_regular where aui_codigo = #{a}) and i.inf_codigo =
(select inf_codigo from tb_iau_itens_auto where aui_codigo = #{a}) and
a.aui_codigo<>#{a} and a.aui_codigo = i.aui_codigo)))")

    print reinc[0].age
  end

the 'a' and the 'x' variables have the same value(11674) and the same
type(FixNum).Curiously,I can run my query using the 'a' variable,but I
cannot run it using the 'x' variable.What am I doing wrong?
Wisccal W. (Guest)
on 2009-04-18 13:19
Rafael R. wrote:
> Hi all,
>

Have you looked at the SQL generated in the log directory?
Rafael R. (Guest)
on 2009-04-20 17:51
Wisccal W. wrote:
> Rafael R. wrote:
>> Hi all,
>>
>
> Have you looked at the SQL generated in the log directory?

Yep..

If I grab the sql in the output directly in the pgAdmin and execute it,I
get the correct result.
Harold (Guest)
on 2009-04-20 21:25
(Received via mailing list)
What kind of error do you get, exactly?

On Apr 16, 1:10 pm, Rafael R. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.