Frederick Cheung wrote in post #967208:
> On Dec 8, 3:39pm, Tim Shaffer <timshaf...@me.com> wrote:
>> On Dec 7, 4:12pm, Marnen Laibow-Koser <li...@ruby-forum.com> wrote:
>>
>> > Look up the RDoc for ActiveSupport::Cache::Store. You'll need to use
>> > the interface described there (at least in Rails 2).
>>
>> Thanks. Turned out to be way simple...
>>
>> @menu_items = Rails.cache.fetch(:menu_items_all) { MenuItem.all }
>>
> Although this is sort of wasteful if you're also fragment caching in
> the view (wasteful in that you put data in the cache that you don't
> use, and wasteful of one roundtrip to your memcache).

But Memcached round trips are pretty cheap, since everything is in 
memory.

> There isn't really a great way to say in rails "this code here only
> exists to support this fragment in the view, so don't bother executing
> it if you're just going to display the fragment from the cache
> anyway".
> In some cases wrapping the database access up in a helper can work,
> but calling models straight from your helpers isn't particularly nice.

I think DB access in a helper breaks MVC in most cases, because the 
helper is really part of the view layer.

Concerns like this are contributing to a growing feeling on my part that 
Rails-style MVC may be a mistake for certain types of complex Web 
applications.  The question is whether something better exists... :)

Note also that I am *not* advocating breaking MVC while using Rails.

> Another solution is the interlock plugin
> http://blog.evanweaver.com/files/doc/fauna/interlock/files/README.html
> although I haven't used that myself

Nor have I.  The Cells gem (which I also haven't used) might be useful 
too.

>
> Fred

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to