Topic: Split a string by keywords (catch-all routes)
I am playing about with catch-all routes, but I want to take that a little further than in Ryans Railscast.
The purpose is a search that has different parameters depending on what to search for. The URL should look something like this:
"/find/manager" or "/find/manager+worker"
This can be extended with:
"/find/manager/tagged/teamwork" or "/find/manager+worker/tagged/teamwork"
I hope you can see that there are 2 keywords in this example: "find" and "tagged". There will be more later on, but let's keep is simple for now. What I need to do now is to search the URL for the keywords I defined (find, tagged) and get the element after this to place my search variables.
I don't really know which way is the best to go now. Should I treat params[:path] as array or string?
If I treat it as array I can look for the occurance of my keyword and get the array element after this. If I treat it as string I'll have to use regular expressions to fetch the value between the keyword and the next "/" of the URL. Anyone has experience with what I am trying to do and could lead me into the right direction?
Any help is much apprechiated.