vigetlabs / nav_lynx

Rails helper to generate navigation links with a selected class.
http://viget.com/extend/rails-selected-nav-link-helper
MIT License
74 stars 19 forks source link

Support partial query paramater match #10

Open mackermedia opened 10 years ago

mackermedia commented 10 years ago

Currently the request matching is on either full url or segment.

I have a scenario where my link is: http://example.com/stores?category=electronics and this is working just fine.

However, when we add a second query parameter (eg. http://example.com/stores?category=electronics&order=name-) nav_lynx no longer shows the link as "selected".

I propose adding an option for param_is_included: true.

This would parse query params and then look to see if the nav_lynx helper link's query parameter is included in the parsed collection of query parameters.

Thoughts @brianjlandau, @greypants, @Fosome ?

Fosome commented 10 years ago

So you want to be able to ignore the query portion of a URL optionally? Seems pretty legit.

mackermedia commented 10 years ago

Well not exactly ignore the whole query portion. I believe there's already an option for that. In this case I'd like it match the query portion when it's present regardless of whether or not there are additional query parameters.

Does that make sense?

Fosome commented 10 years ago

Yes it does. Matching on partial queries, i.e. if the link is a proper subset or the current URL.

Maybe something like partial_query: true then?

mackermedia commented 10 years ago

Good call. Better name indeed.

brianjlandau commented 10 years ago

This sounds great. My only concern is I am interested in limiting complexity that can make it difficult to maintain this gem. So one thing I'd like to see is us reuse Rack or Rails code for parsing the params. Also, how about the option name :match_partial_query? Other than that let's see some code and go from there.

reagent commented 10 years ago

@mackermedia any update on this? Need help?