Question

We're looking at going a little more restful in our URL scheme and for the most part it make sense to us. The one thing we can't find a good example of is how do you handle a separate search screen? We need to show a list of cards to the user but they always need to do a search first.

Any ideas or examples out there?

Was it helpful?

Solution

You can treat Search as RESTful resource ...

Ryan Bates explains the pattern here: http://railscasts.com/episodes/111-advanced-search-form

This fit the bill?

OTHER TIPS

I'd set up a scope in in my model class that does the search you want; just add a lambda to the scope so you can pass in the search term, should look something like this:

scope :matching_attribute, lambda{|your_search_term| where(:model_attribute => your_search_term)}

and then in your controller's index, just check for the request param (whatever you're naming it) and do the appropriate thing there

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top