using rails 3.0.1 and ruby 1.9.2-p0
in the rails console I’m seeing the following:
ruby-1.9.2-p0 > "login_controller".classify
=> "LoginController"
ruby-1.9.2-p0 > {:controller=>"login", :action=>"show"}[:controller]+"_controller".classify
=> "login_controller"
ruby-1.9.2-p0 > "login_controller" == {:controller=>"login", :action=>"show"}[:controller]+"_controller"
=> true
Why is classify returning ‘login_controller’ for the one, and ‘LoginController” for the other, when ruby says both strings are equal?
Your order of operations isn’t right. In the second example, the implicit brackets are going like this:
since
.binds before+. To fix it, you can do this:ie, include the brackets yourself.