[Rails] Re: Using variables in dynamic finds

2008-09-29 Thread Gearóid O'Ceallaigh
Working perfectly, thanks a lot. On 25 Sep, 09:44, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On Sep 25, 9:40 am, Thorsten Müller <[EMAIL PROTECTED]> wrote: > > > > > @upcoming_events = Event.find(:all, :conditions => ["venue_id IN (?) > > AND date > '?' ", @nearby_venues.join(","), Time.now.

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Erol Fornoles
On Sep 25, 6:01 pm, Thorsten Müller <[EMAIL PROTECTED]> wrote: > Depends on some details. the results: > > Date.today: "2008-09-25" > Time.now: "2008-09-25 11:56:21" > > So Date.today would get you all records of today, including those from > the morning to now. > Time.now includes the time, ignor

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Thorsten Müller
> I think Date.today might be more logically correct than using > Time.now, though. Depends on some details. the results: Date.today: "2008-09-25" Time.now: "2008-09-25 11:56:21" So Date.today would get you all records of today, including those from the morning to now. Time.now includes the tim

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Erol Fornoles
On Sep 25, 4:44 pm, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On Sep 25, 9:40 am, Thorsten Müller <[EMAIL PROTECTED]> wrote: > @upcoming_events = Event.find(:all, :conditions => ["venue_id IN (?) > AND date > ? ", @nearby_venues, Time.now ], order => 'date') > > Active Record takes care of the

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Frederick Cheung
On Sep 25, 9:40 am, Thorsten Müller <[EMAIL PROTECTED]> wrote: > > @upcoming_events = Event.find(:all, :conditions => ["venue_id IN (?) > AND date > '?' ", @nearby_venues.join(","), Time.now.to_s(:db) ], > order => date) A minor tidyup: the above is equivalent to @upcoming_events = Event.find(

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Thorsten Müller
several details wrong here :) - :conditions => {...} is defining a hash. You can't use "and" within that, only key/value pairs. So you must use one of the alternative syntax variants: @upcoming_events = Event.find(:all, :conditions => ["venue_id IN (?) AND date > '?' ", @nearby_venues.join(","),

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Frederick Cheung
On Sep 25, 9:20 am, Gearóid O'Ceallaigh <[EMAIL PROTECTED]> wrote: > Cheers, that worked perfectly. > > > @upcoming_events = Event.find(:all, :conditions => {:venue_id => > @nearby_venues and :date > @today}, order => date) > > This doesn't work either however, any advice? Oops, that doesn't ev

[Rails] Re: Using variables in dynamic finds

2008-09-25 Thread Gearóid O'Ceallaigh
Cheers, that worked perfectly. What I'm trying to do now is to list the events which belong to these "nearby_venues" and which occur after todays date. I have no problem in getting the events from the nearby venues but am having problems when trying to couple this with the date condiiton. My cur

[Rails] Re: Using variables in dynamic finds

2008-09-24 Thread Thorsten Müller
@nearby_venues = Venue.find(:all, :conditions => {:location_id = >@location.id}, :order => 'name') should work in that case --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this

[Rails] Re: Using variables in dynamic finds

2008-09-24 Thread Erol Fornoles
On Sep 24, 4:53 pm, Gearóid O'Ceallaigh <[EMAIL PROTECTED]> wrote: > Hi > > I'm trying to perform a simple find on a class but am having trouble > implementing it. > > What I want to perform a dynamic find for each different user. The > user's location would be variable and I want to display all t