Hi,
I''m trying to build a simple mechanism for pre-caching a bunch of files
by iterating over a hash of options from within a controller:
#site.controller:
for options in [
{ :controller => "site", :action => "welcome" },
{ :controller => "site", :action => "about" },
{ :controller => "site", :action => "contact" },
{ :controller => "site", :action => "funding" },
{ :controller => "site", :action => "funding",
:params => { ''page'' => "proposal.html" } },
{ :controller => "site", :action => "funding",
:params => { ''page'' => "submissions.html" } },
{ :controller => "site", :action => "funding",
:params => { ''page'' => "production.html" } }
] do
rebuild_page(options)
end
with the following in the application.rb controller:
# handle all regeneration of pages - available to all controllers
def rebuild_page(options, path = nil)
# get rid of the existing one
expire_page(options)
# pull the page in as a string
# set page parameters first:
if options.has_key?(:params)
options[:params].each_pair {
|key, value|
@params[key] = value
}
end
page = render_to_string(options)
# write the rendered content to the right place
cache_page(page, options)
end
I can see the parameters have been set, but somehow the ''page''
parameter never gets processed by the funding action, so I end up with a 4 pages
that all have the same content (the simple funding page). My
''funding'' action also has a bunch of other @vars which seem to
not be available when rendering the template.
I presumed that the render_to_string method would process the :action with all
available parameters, but I can''t make it do so - am I doing it wrong?
dorian
--
--
I do things for love or money