log belongs_to :viewer
log belongs_to :episode
Here's the table:
<table-plus with="&@logs" fields="this, viewer.name, episode.name, created_at">
this this.viewer.name this.episode.name
1 Stan Mr. F
2 Mike Cabin Show
The only problem is, I don't see how to search on viewer.name and
episode.name in apply_scopes. The following doesn't work.
@logs = Log.apply_scopes(
:search => [params[:search], :viewer, :episode],
:order_by => parse_sort_param(:viewer, :episode) )
Thanks,
- Scott
Please submit patch to add this feature to search scope :)
Tom
OK. Is this what you're picturing?
<table-plus with="&@logs" fields="this, Viewer.name,
Episode.description, created_at">
@logs = Log.apply_scopes(
:search => [params[:search], "Viewer.name", "Episode.description"],
:order_by => parse_sort_param("Viewer.name", "Episode.description") )
Pass strings as well as symbols to apply_scopes?
Or is there a less manual / more hoboish way of specifying the joins?
I guess something like that might work. Having joins automatically
added to the query seems like it might get messy though. E.g. what if
you have an :include clause as well?
If someone can come up with a good way of doing this that would be
good news, but I'm inclined to keep it simple for now and say you need
to define your own named scope for your specific needs
Another idea would be to look at the various plugins out there for
making :conditions clauses easier - like ezwhere
Tom