I’m completely new to RoR and also new to programming in an MVC
The Pragmatic Programmers guide to Rails says, temptingly:
“After filters can be used to modify the outbound response, changing the
headers and content if required. Some applications use this technique to
perform global replacements in the content generated by the controllerâ??s
templates (for example, substituting a customerâ??s name for the string
in the response body).”
This, "substituting a customerâ??s name for the string ", is
exactly the simple task I’m trying to accomplish, however I can’t find
how to do it.
I think what I want to do is gsub(/UserName/, ‘Matthew’), however, I’m
clearly missing something. Here’s what I use:
class DisplayController < ApplicationController
@contentdivs = Contentdiv.thispage(params[:page])
@contentdivs contains bits of html that show.rhtml nicely formats.
thispage() selects only those with an attribute that matches the page
The error I get is “private method `gsub’ called for
#Array:0x385df18”. I’m certain the solution is blindingly simple.