From: Xeno Campanoli Date: 2008-05-25T09:36:37+09:00 Subject: Re: Railsy Question about redefining ruby methods... Phillip Gawlowski wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Xeno Campanoli wrote: > > | No no no no no no! I have all the other stuff working. I've got > | UserDir and ProxyPass directives that get all the stuff set up initially > | from my http://host:n to my http://host/~u1/rrsw like I want. All I > | need now is to get all the URLs that are presently rendered in the > | markup as /something to be ~u1/rrsw/something. That is all I need. I > | have the rest working. > > Why? Is the application not working? The webserver is smart enough to > construct the link properly, so that links should Just Work(tm). > > And you don't really want absolute links, either, as this will break > once you move the application to another server. They aren't absolute at all. What I get rendered by rails link_to, for instance, is things like Something. What I need is still a relative link, which is Something for u1, and Something for u2. I originally expected there would be a simple rendering configuration for this in rails, and spent much of yesterday and part of Thursday asking on the #rubyonrails IRC. Not only did those folks know of no such configuration, but they didn't seem to even understand the OO need for encapsulation, nor the logical reason, nor the traditional Unix Webserver usage of ~user, nowadays configured with the UserDir Apache directive. Anyway, those are mostly Rails oriented issues and problems, which are interesting, but not completely appropriate here. What is appropriate to address here is the whole idea of redefinition of a Ruby method like link_to which is embedded in some arbitrary community/tree of modules and/or classes. I've never done much of that, and I know it's part of the real power that experienced OO users acquire in such environments. Now ideally it would be nice if some Rails supergeek came out of the woodwork and said there in fact was a configuration to change the rendering, but it looks like there's not. You wouldn't want to change the URLs that Rails renders with an external rewrite in Apache if you can help it because that breaks encapsulation, which is a standard and a good ethic in OO programming any reasonable engineer would recognize, and given the ability to simply redefine link_to, url_for, or whatever other methods I use can achieve what I want, and not only that perhaps help lead to a future Rails configurability on such things in a reasonably elegant matter, presuming that it in fact doesn't yet exist, seems to me to make that the proper direction for me at this point. Thanks for asking. > > Otherwise, look at Rails' routes.rb. > > - -- > Phillip Gawlowski > Twitter: twitter.com/cynicalryan > Blog: http://justarubyist.blogspot.com > > Youth -- not a time of life but a state of mind... a predominance of > courage over timidity, of the appetite for adventure over the love of ease. > ~ -- Robert Francis Kennedy (1925-1968) > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkg4rxoACgkQbtAgaoJTgL/YBACgpy5rJGR6uwqjmVNp2254HsrH > 2SQAoKccu01YWo+xnag0qY2GTeKqYKCm > =oIi1 > -----END PGP SIGNATURE----- > >