link_to a search with query string

9 views
Skip to first unread message

ange52

unread,
Nov 12, 2009, 12:33:37 AM11/12/09
to Searchlogic
Hi all,

I'm still pretty new to Rails and I need to spend more time
understanding routing, so I'm hoping that this will be a pretty simple
question to answer. I'm trying to create a link_to from one part of my
app to a specific set of search results in another part of my app. The
URL of the search results looks like:

http://localhost:3000/activities/search?search[order]=&search[created_by_id_equals]=30&search[hidden]=1

I want to offer a link to this page from another controller, that way
users can jump directly to these search results without having to type
the info into the necessary form.

Any tips for me? Thanks so much everyone.

Andy Koch

unread,
Nov 12, 2009, 1:01:32 AM11/12/09
to Searchlogic
unless I'm mistaken, there's nothing in SL to generate links like that

the link you show would have been created from a get request from a
search form

although there is nothing to stop you making these yourself - the
pattern is pretty straightforward

just

link_to "Your Link Text", "/activities/search?search[order]=&search
[created_by_id_equals]=30&search[hidden]=1"

of course, you'll want to make the url bit something dynamic

Colin Angevine

unread,
Nov 12, 2009, 1:24:24 AM11/12/09
to searc...@googlegroups.com
Thanks so much for the quick reply. I was having all sorts of issues with url encoding before and wondering if there was a proper way to create links to search results. But with your feedback, I'm having some luck now just creating the url myself by hand.

Thanks again!
Reply all
Reply to author
Forward
0 new messages