Re: [Rails] Proper use of the where method om ActiveRecord.
On 13 November 2012 20:40, byrnejb <byrnejb@harte-lyne.ca> wrote:
> I am trying to determine what is going on with the following code:
>
> In AR
> def self.all_billables
> where( :is_billed => false )
> end
>
> returns 2 records.
>
> def self.all_billables
> where( "is_billed" => false )
> end
>
> also returns 2 records.
>
> In sqlite3
> sqlite> select * from tests where ( "is_billed" = 'false' );
>
> returns 2 records.
>
> However, if I use these forms in AR then I get nothing returned:
>
> def self.all_billables
> where( %Q( "is_billed" = 'false' ) )
> end
>
> def self.all_billables
> where( "is_billed = 'false'" )
> end
>
>
> What am I missing here?
Look in log/development.log to see what the difference is in the
queries (which should be logged there). Then it will probably make
sense.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home