views:

28

answers:

1

Hello,

I'm using the Rails 3 nav plugin simple-navigation: http://github.com/andi/simple-navigation

In the configuration file you can setup a regex to determine what element gets the ".selected" class.

Example:

primary.item :projects, 'Projects', project_path, :class => "sideNav-main", :highlights_on => /\/projects/

The above works fine for an URL like /projects/ but at this time I'm adding deep linking to the app which breaks the above.

Q: How can I update the REGEX /\/projects/ to support URLs like /#/projects/ or /#/projects/3

thanks

A: 

You must be missing some kind of constraint, because this seems easy enough?

The regex /^\/#\/projects/ will match only project URLs starting with a hash mark.

Winfield
thanks. that doesn't seem to be working. Maybe it's a plugin issue.
AnApprentice
It sounds like you're not doing your route requirements correctly to apply the regex. Here's a demo of that regex on the strings you provided:irb(main):001:0> foo = '/#/projects/3'irb(main):007:0> match = foo.match /^\/#\/projects/=> #<MatchData:0x40741a4>irb(main):008:0> match[0]=> "/#/projects"
Winfield