Clarification of how controllers and views work together...

Bob Hutchison hutch at recursive.ca
Mon Mar 12 00:10:37 EDT 2007


Hi,

So I've started mucking about with Merb. I'm doing some experimenting  
with some product ideas. Things are working out quite well, Merb is a  
pleasure to use. It seems very fast too. A couple of rough spots but  
that might be me, if they are still chaffing after a few more days  
I'll mention them.

One thing...

I wrote a controller and a view with several partials. Works fine.  
Now lets say that I have to generate a bunch of static files that are  
exactly like that page generated by that controller.

So I generated an array of hashes, where each hash provides the  
information needed by the views and partials. In a loop, I set an  
instance variable, say @data, to each hash in the array then render  
the view. It works the first time, subsequent times produce pages  
identical to the first. I put a few puts in the view so I know it is  
executing and isn't caching its results. When I look at object_ids  
I'm starting to see what might be going on. The object_id of the  
@data object is never the same as in the controller, and it never  
changes during that request. Next request it is different but doesn't  
change.

Sounds like some kind of cache.

Now, I'm thinking I'm either out of luck, or there is a trivial thing  
I have to do to loosen the view's grip on that copy of @data that it  
has.

Any help is appreciated.

Cheers,
Bob

----
Bob Hutchison                  -- blogs at <http://www.recursive.ca/ 
hutch/>
Recursive Design Inc.          -- <http://www.recursive.ca/>
xampl for Ruby                 -- <http://rubyforge.org/projects/xampl/>





More information about the Merb-devel mailing list