table-plus search on joined columns?

10 views
Skip to first unread message

Scott Bronson

unread,
Jan 14, 2009, 6:17:56 AM1/14/09
to hobousers
I'm trying to use a table-plus to display log messages

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

Tom Locke

unread,
Jan 14, 2009, 10:27:21 AM1/14/09
to hobo...@googlegroups.com
> The only problem is, I don't see how to search on viewer.name and
> episode.name in apply_scopes.

Please submit patch to add this feature to search scope :)

Tom

Scott Bronson

unread,
Jan 14, 2009, 5:13:20 PM1/14/09
to hobo...@googlegroups.com

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?

Daniel M

unread,
Jan 19, 2009, 6:03:56 PM1/19/09
to Hobo Users
This is in my whish list too !

kevinpfromnm

unread,
Jan 19, 2009, 6:55:38 PM1/19/09
to Hobo Users

Daniel M

unread,
Jan 19, 2009, 7:33:50 PM1/19/09
to Hobo Users
Thanks kevin

On Jan 19, 11:55 pm, kevinpfromnm <kevinpfro...@gmail.com> wrote:
> Since nobody added it to lighthouse yet...http://hobo.lighthouseapp.com/projects/8324/tickets/372-apply-scopes-...

Tom Locke

unread,
Jan 21, 2009, 4:29:30 AM1/21/09
to hobo...@googlegroups.com
> OK. Is this what you're picturing?
>
> <table-plus with="&@logs" fields="this, Viewer.name,
> Episode.description, created_at">

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

Reply all
Reply to author
Forward
0 new messages