Hi,
you would probably want to do this in yout Artist model
def active_dates
tour_dates.find(:all, :conditions => "date >
now()", :order=>''dates'')
end
or with an eager load(@artist Artist.find :all, :include=>:tour_dates) (no
attributes here
on :tour_dates)
def active_dates
tour_dates.select {|date| d >now()}
end
Charly
On 8 fév, 07:23, Michael Bingaman
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> I''ve got a database schema that is an artist with many tour_dates.
I''m
> trying to grab the artist info and active tour dates at the same time.
> Simple enough:
>
> In the controller:
> @artist = Artist.find(params[:id], :include => :tour_dates)
>
> Now I want to include only the tour_dates that happen after the first of
> the current month. This is what I tried:
>
> @artist = Artist.find(params[:id], :include => :tour_dates.active_dates)
>
> and added
>
> def self.active_dates
> find(:all,
> :conditions => "date > now()",
> :order => "date")
> end
>
> to the tour_date model, just to see if i could get tour_dates after
> right now to display. It doesn''t work quite the way I''d
expect. How
> would you do this? If you need to see more of my models or controllers
> let me know.
>
> I''m really just getting rolling on this so any help is
appreciated.
> I''ve got some books, I just didn''t see anything like this
in them.
>
> I also am grabbing
> @artists = Artist.active_artists (similar model to the above) for a menu
> on the page, which I realize may be redundant, but I can''t figure
out
> how to grab all the artist names and ids, but also everything for one
> specific artist.
>
> Thanks!
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---