From: Leslie Viljoen Date: 2008-02-18T18:40:52+09:00 Subject: Re: [ANN] Webby 0.7.2 On Feb 17, 2008 11:41 PM, Leslie Viljoen wrote: > On Feb 15, 2008 6:18 PM, Tim Pease wrote: > > > > > 2. How do you create links to other content pages without specifying > > > the URL directly? > > > > <%= link_to_page( :title => "Your Page Title" ) %> > > Because the "url_for" function produces url's that start with a "/", > I cannot open my generated index.html as a file on my harddrive - > all the links are absolute. I changed the url_for function to leave > out the leading slash and now everything seems to work locally > and through a server. Can you think of a problem this may cause? Here's the code: def url_for( *args ) opts = Hash === args.last ? args.pop : {} obj = args.first anchor = opts.delete(:anchor) escape = opts.has_key?(:escape) ? opts.delte(:escape) : true url = Webby::Resource === obj ? obj.url : obj.to_s url = escape_once(url) if escape url << "#" << anchor if anchor url = url[1..-1] if url.length > 1 return url end .. I just added the third-last line. Perhaps better would be to change obj.url for each object.