Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6755 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Rails 1.2.0 routing and symlink woes

Reported by: trevor Assigned to: bitsweat
Priority: normal Milestone: 1.2 regressions
Component: Railties Version: 1.2.0rc1
Severity: normal Keywords: rails_root symlink expand_path pathname
Cc:

Description

Upgrading from Rails 1.1.6 to Rails 1.2.0 broke any of my applications living in subdirectories. A URL to a project on the Apache server may be formatted like http://myserver.com/myapp. On the filesystem there would be a symbolic link from /var/www/htdocs/myapp to /home/rails/myapp/public.

The error I would receive when clicking on “About your application’s environment” link on the welcome page was this routing error: no route found to match "/rails/info/properties" with {:method=>:get}

After examining a fresh install, I noticed the fix was to hardcode the RAILS_ROOT variable in the application’s environment.rb. For reference, here’s what I saw in the logs that tipped me off:

Rendering /var/www/htdocs/myapp/../config/../vendor/rails/actionpack/lib/ action_controller/templates/rescues/layout.rhtml (not_found)

Change History

12/07/06 20:19:06 changed by trevor_wennblom

  • component changed from ActionPack to RailTies.

01/17/07 13:07:24 changed by jonathan_viney

  • keywords set to 1.2regression.

I just hit this on 1.2.0rc2. It needs to be fixed or at least noted in an upgrade guide.

(follow-up: ↓ 4 ) 01/25/07 13:03:07 changed by bitsweat

  • milestone changed from 1.x to 1.2.

The given RAILS_ROOT appears it would work if you'd symlink to the public dir rather than a subdir. What's the fix?

(in reply to: ↑ 3 ) 01/25/07 21:41:11 changed by jonathan_viney

Replying to bitsweat:

The given RAILS_ROOT appears it would work if you'd symlink to the public dir rather than a subdir. What's the fix?

The hosting server used a symlink of ~/html pointing to ~/myrailsapp/public.

Setting a RAILS_ROOT of /home/jonathan/myrailsapp in environment.rb fixed the problem.

(follow-up: ↓ 6 ) 01/28/07 04:28:04 changed by ulysses

jonathon: Would setting RAILS_ROOT to the realpath work? See ri Pathname#realpath

(in reply to: ↑ 5 ) 01/29/07 00:08:17 changed by jonathan_viney

Yes, a call to realpath in config/boot.rb fixes the problem.

Replying to ulysses:

jonathon: Would setting RAILS_ROOT to the realpath work? See ri Pathname#realpath

01/30/07 13:57:11 changed by Fjan

Confirmed, changing line 8 in boot.rb to include realpath() fixes this. Thanks.

root_path = Pathname.new(root_path).cleanpath(true).realpath().to_s

02/12/07 03:01:51 changed by ulysses

Excellent, hopefully we can throw this in sometime and get rid of that fugly RAILS_ROOT path.

02/12/07 06:02:47 changed by bitsweat

I don't see how this regressed, though. Why did it work in before 1.2 and what change broke it?

I think using realpath on everything but Windows is sensible, and we can just use expand_path there since Windows doesn't have symlinks which would break it.

03/04/07 13:42:18 changed by bitsweat

  • keywords deleted.
  • owner changed from David to bitsweat.
  • milestone changed from 1.2.3 to 1.2 regressions.

03/18/07 13:36:02 changed by bitsweat

  • keywords set to rails_root symlink expand_path pathname.
  • status changed from new to closed.
  • resolution set to fixed.

03/18/07 13:47:28 changed by bitsweat

[6447] 1-2-stable