I''m just starting with rails and trying out tracks. I''ve installed it with lighttpd, and trying to run it from a subdir of the document root. ie rails.domain/tracks/. link_to seems to respect this, giving relative URLs. However, link_image_to, stylesheet_link_tag and javascript_include_tag don''t seem to respect the /tracks/ bit. For example: link_image_to("edit", { :action => "edit", :id => @context.id }, :title => "Edit item", :size => "10x10") gives: <a href="/tracks/context/edit/1" title="Edit item"><img alt="Edit" height="10" src="/images/edit.png" width="10" /></a> Am I missing something or is this a bug? Nicholas
On Fri, 18 Mar 2005, Nicholas Lee wrote:> I''m just starting with rails and trying out tracks. > > I''ve installed it with lighttpd, and trying to run it from a subdir of > the document root. ie rails.domain/tracks/. > > link_to seems to respect this, giving relative URLs. However, > link_image_to, stylesheet_link_tag and javascript_include_tag don''t > seem to respect the /tracks/ bit. > > > For example: > > > link_image_to("edit", { :action => "edit", :id => @context.id }, > :title => "Edit item", :size => "10x10") > gives: > <a href="/tracks/context/edit/1" title="Edit item"><img alt="Edit" > height="10" src="/images/edit.png" width="10" /></a> > > > Am I missing something or is this a bug?show us your .htaccess and routes.rb. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
On Thu, 17 Mar 2005 15:26:49 -0700 (MST), Ara.T.Howard <Ara.T.Howard-32lpuo7BZBA@public.gmane.org> wrote:> show us your .htaccess and routes.rb.Yes, sorry was just thinking I should have sent that. Plus I was trying to figure out routes.rb for one particular case. routes.rb has been modifed to: map.connect ''tracks/'', :controller => ''todo'', :action => ''list'' map.connect ''tracks/add_item'', :controller => ''todo'', :action => ''add_item'' # Install the default route as the lowest priority. map.connect ''tracks/:controller/:action/:id'' The important lines from lightttpd.conf are: alias.url = ( "/tracks/" => "/home/nic/devel/ruby/tracks/public/" ) url.rewrite = ( "^/tracks$" => "/tracks/dispatch.fcgi?controller=todo&action=list", "^/tracks/$" => "/tracks/dispatch.fcgi?controller=todo&action=list", "^/tracks/([\-_a-zA-Z0-9]+)/([\-_a-zA-Z0-9]+)/([\-_a-zA-Z0-9%]+)$" => "/tracks/dispatch.fcgi?controller=$1&action=$2&id=$3", "^/tracks/([\-_a-zA-Z0-9]+)/([\-_a-zA-Z0-9]+)$" => "/tracks/dispatch.fcgi?controller=$1&action=$2") ... fastcgi.server = ( ... ".fcgi" => ("localhost" => ( "socket" => "/tmp/rails.socket", "bin-path" => "/home/nic/devel/ruby/tracks/public/dispatch.fcgi" ) I was trying to follow action_view/helpers/url_helper.rb but I can''t follow "@controller.send" in url_for, as this function doesn''t seem to exist? I noted this line as well: "image_options = { "src" => src.include?("/") ? src : "/images/#{src}" }" I''ve also discovered that: http://localhost/tracks/feed/na_feed?token=sljsd&name=admin has some routing (I guess) issues. http://manuals.rubyonrails.com/read/chapter/65 isn''t very clear on how to deal with CGI ? tokens. Thanks. Nicholas
Nicholas Lee
2005-Mar-18 10:45 UTC
url.rewrite for get params (was Re: Respecting URL subdir?)
On Fri, 18 Mar 2005 11:57:33 +1300, Nicholas Lee <emptysands-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > http://localhost/tracks/feed/na_feed?token=sljsd&name=admin has some > routing (I guess) issues.I figured out that I needed to add the following: "^/tracks/([\-_a-zA-Z0-9]+)/([\-_a-zA-Z0-9]+)\?(.*)" => "/tracks/dispatch.fcgi?controller=$1&action=$2&$3" as the standard example don''t take into account the addition of ''get params''. Note, server.error-handler-404 = "/dispatch.fcgi" doesn''t seem like a nice way to this. There should a better method that allows one to have /tracks/ and /blog/ served by the same lighttpd instances. Rather than being forced towards tracks.domain and blog.domain or using apache. Something like "^/tracks/(.*)" => "/tracks/dispatch.fcgi?$1". Although obviously without the cycle reference. In fact it seems to me that dispatch.fcgi should ''know'' when to call app/ or when to serve something from public/. I''m not experienced enough yet to figure out how do this or why I shouldn''t. Still trying to figure out my other issue. Nicholas