Problem with current_page? & request.url

Hi everyone.

(Rails 4.1.x)

I’m trying to add a css class in a view but only if
current_page?(courses_path) #=> true. The problem I’m having is that
is never returning true even if (according to the docs) it should.

I created a gist with a short debugging session where I think the
gets shown really clear:

In summary, I think something’s going wrong with rails/rack’s request
parsing and SCRIPT_NAME + PATH_INFO variables where the initial slash in
“/courses” is not being processed. but it’s clearer if you look at the

Anyone having a similar issue?


What is in your rake routes output? Do you have /courses route?

current_page?(controller: params[:controller], action: params[:action])
not a recommended way to check as params[:controller] and
are created during the action dispatch flow.

what is the output for this ?

current_page?(controller: ‘courses’, action: ‘index’)

On Sat, Mar 14, 2015 at 7:47 AM, Dmitry S. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs