Render_to_string troubles

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:


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

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

# 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
page = render_to_string(options)

# write the rendered content to the right place
cache_page(page, options)


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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs