문제

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?

도움이 되었습니까?

해결책

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?

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top