On Sun, Dec 7, 2008 at 8:10 PM, Mislav Marohnić
<[EMAIL PROTECTED]> wrote:
> Changing Rails.root to a Pathname was great and all (I'm a strong believer
> that us Rubyists shouldn't handle paths or URLs as String objects), but
> there's one thing I've discovered just now that kinda ruins the joy.
> With string paths, these two lines are equivalent:
>   "#{Rails.root}/tmp/foo"
>   Rails.root + "/tmp/foo"
> Now that Rails.root is a Pathname, they do totally different things. While
> the first one becomes "/path/to/app/tmp/foo", the second becomes just
> "/tmp/foo" because Pathname overloads the "+" operator in a similar way that
> URI does it.
> Thoughts? Think this may break apps? It broke mine, but I'm not complaining
> -- being subscribed to edge commits helps me resolve these kinds of issues
> in a matter of seconds. To other folks upgrading to 2.3, this may take much
> longer to track down.

Maybe we could issue a warning when people try to call Pathname#+ with
a String argument? And suggest the usage with Pathname#join.

If people still want to concatenate, they should do it the ugly way:
Rails.root.to_s + '/tmp/foo'.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to