params['controller'].to_s + '/' # => "posts/" params['controller'].to_s +'/' # => NoMethodError: undefined method `+@' for "/":String
> params['controller'].to_s +'/' # NoMethodError: undefined method `+@' for "/":String > params['controller'].to_s(+'/') # NoMethodError: undefined method `+@' for "/":String
如果在to_s方法调用结束时明确包含括号,则问题就会消失:
> params['controller'].to_s() +'/' => "posts/"