On Dec 12, 1:30 pm, "David Masover" wrote:
> Yes, this will work with strings also -- but Pathnames are smart enough to
> actually interpret those relative paths before passing them to 'require' and
> friends.
... which is a helpful feature -- you can end up requiring a file
twice if you pass tw
On Wed, Dec 10, 2008 at 1:05 PM, Michael Koziarski wrote:
>
> > Pathname #+ just coerces the argument to a pathname before
> > concatenating, so that it can return another pathname instance. The
> > problem with Mislav's example is the preceding "/" on "/tmp/foo":
> >
> >>> (Rails.root + "/tmp/foo
> Pathname #+ just coerces the argument to a pathname before
> concatenating, so that it can return another pathname instance. The
> problem with Mislav's example is the preceding "/" on "/tmp/foo":
>
>>> (Rails.root + "/tmp/foo").to_s
> => "/tmp/foo"
>>> (Rails.root + "tmp/foo").to_s
> => "/Users
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.
>
Pathname #+ just coerces the argument to a pathname before
concatenating, so that it can return another pathname instance. The
problem with Mislav's example is the preceding "/" on "/tmp/foo":
>> (Rails.root + "/tmp/foo").to_s
=> "/tmp/foo"
>> (Rails.root + "tmp/foo").to_s
=> "/Users/geoff/Sites/
I do think this should be addressed. Why is the "+" operator
overridden in Pathname in the first place? Is there some benefit to
this way of concatenating that I'm not seeing? Rails.root + "/foo"
should append "/foo" to the end of Rails.root. That's what the code
says anyway.
Regards,
Ryan
On
I know of at least two of my apps that will break. But I also agree
with the sentiment of
dealing with a slightly higher abstraction than just strings when
working with the filesystem.
So I'm willing to pay the (small) price and I thank you for bringing
it to my attention!
On Dec 7, 5:10 pm, "Mi