Reputation: 742
Here's the route:
get "search(/:search)", to: "posts#index", as: :search
Now if I'm at /search/somethingsomething
and the view is:
- if current_page?(search_path)
= (do something)
then that something isn't being done. If I remove the parenthesis around :search
, however (i.e. get "search/:search" ...
), then it works. What gives?
Upvotes: 1
Views: 628
Reputation: 742
Never mind. Solved it by replacing the condition with:
- if current_page?("/search/#{params[:search]}")
Upvotes: 0
Reputation: 1887
You can use this condition
current_page?(controller: 'posts', action: 'index')
when you use search_path
in condition it generated without optional parameters
Upvotes: 1