1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fixed caching for root and Routing for getting back the current url

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@727 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-02-21 01:01:24 +00:00
parent 824558816a
commit 48a44b77c1
4 changed files with 12 additions and 5 deletions

View file

@ -90,7 +90,7 @@ module ActionController #:nodoc:
private private
def page_cache_path(path) def page_cache_path(path)
page_cache_directory + path + ".html" page_cache_directory + (path.empty? ? "/index" : path) + ".html"
end end
end end

View file

@ -211,11 +211,14 @@ module ActionController
# Note that we *do* return immediately if # Note that we *do* return immediately if
def generate(options, request) def generate(options, request)
raise RoutingError, "There are no routes defined!" if @routes.empty? raise RoutingError, "There are no routes defined!" if @routes.empty?
options = options.symbolize_keys options = options.symbolize_keys
defaults = request.path_parameters.symbolize_keys defaults = request.path_parameters.symbolize_keys
expand_controller_path!(options, defaults) expand_controller_path!(options, defaults)
defaults.delete_if {|k, v| options.key?(k) && options[k].nil?} # Remove defaults that have been manually cleared using :name => nil defaults.delete_if {|k, v| options.key?(k) && options[k].nil?} # Remove defaults that have been manually cleared using :name => nil
options = defaults if options.empty? # Get back the current url if no options was passed
failures = [] failures = []
selected = nil selected = nil
self.each do |route| self.each do |route|

View file

@ -71,11 +71,10 @@ server.port = 8080
server.bind = "127.0.0.1" server.bind = "127.0.0.1"
# server.event-handler = "freebsd-kqueue" # needed on OS X # server.event-handler = "freebsd-kqueue" # needed on OS X
server.modules = ( "mod_rewrite", "mod_access", "mod_fastcgi" ) server.modules = ( "mod_rewrite", "mod_fastcgi" )
server.indexfiles = ( "index.html" ) url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
url.rewrite = ( "^([^.]+)$" => "$1.html" ) server.error-handler-404 = "/dispatch.fcgi"
server.error-handler-404 = "/dispatch.fcgi" # change to dispatch.cgi to run CGI
server.document-root = "/path/application/public" server.document-root = "/path/application/public"
server.errorlog = "/path/application/log/server.log" server.errorlog = "/path/application/log/server.log"
@ -169,6 +168,9 @@ app/helpers
config config
Configuration files for Apache, database, and other dependencies. Configuration files for Apache, database, and other dependencies.
components
Self-contained mini-applications that can bundle controllers, models, and views together.
lib lib
Application specific libraries. Basically, any kind of custom code that doesn't Application specific libraries. Basically, any kind of custom code that doesn't
belong controllers, models, or helpers. This directory is in the load path. belong controllers, models, or helpers. This directory is in the load path.

View file

@ -5,6 +5,8 @@ Options +FollowSymLinks +ExecCGI
# Redirect all requests not available on the filesystem to Rails # Redirect all requests not available on the filesystem to Rails
RewriteEngine On RewriteEngine On
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /dispatch.cgi?$1 [QSA,L] RewriteRule ^(.*)$ /dispatch.cgi?$1 [QSA,L]