ruby - Rails 3 - IF a variable contains a part of the URL? -


I have a variable like / project / 3 / blank blah or / project / 3 or just / projects

< P> What do I have to do, there is an IF statement in the train like this:

If urlPath / projects go ahead

Is there a method for that in Rail / Ruby? ? In addition, there should not be false positives for some, such as books / projects / / writers / MR-projects etc. ...

jquery posting for railing which evaluates them above:

  $ Ajax ({url: '/ navigations / sidenav', // data: {"urlpath": urlpath}, // data: "urlpath =" + urlpath, success: function (e) {$ ("#SideNov Container") Slide Down ("Slow");}});  

In the train you start Starts_with? can use things:

  if paramount [: urlpath] .starts_with? "/ Projects" # ... end  

Definitely fails when a hash evaluates zero lookup, this is where the try method Comes to work:

  If the parameter [: urlpath] .tree (: starts?, "/ Projects") # end ...  

Comments