On Aug 4, 1:08 pm, ct9a <anexi...@gmail.com> wrote:
> hi guys
>
>  in relation to the "find" method in Active Record, can anyone tell me
> how to write the syntax for the following?
>
> 1) entries created within the past 2 hours, AND
> 2) entries that do not have a status of "Sold"
>
> at the moment,  i have the following and i still get a syntax error of
> "NoMethodError: undefined method `%' for #<Hash:0x000000083fa520>"
>
>     @latest_entries = Books.find(:all,
>       :conditions =>  [
>         {
>           :created_at => (Time.now - 6 ) .. (Time.now)
>         },
>         [
>           'status_id != ?'  => Status.find_by_name('sold')
>         ]
>       ],
>       :limit        =>  20,
>       :order        => 'created_at DESC'
>     )
>
> Can someone please help me in terms of the syntax for the conditions
> argument?

You can't mix and match the hash form and the array form of conditions
- has to be all one or all the other.

Fred
>
> Thanks

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to