I have a few questions about how well RoR performs under various
‘irregular’ circumstances. First, how quickly does rails work when
there are potentially lots of embedded ruby expressions (hundreds) per
page? Also, how well does ruby do when there are perhaps hundreds of
database reads per page?
In the app I am designing, there would be a list of messages (let’s
say 50 per page in this example, but it might be more.) Each message
could have 0 from a group of several ‘tags’ applied (funny, serious,
sad, happy, etc…) and I want to to show these tag counts next to the
subject line of the message (only if they are > 0.) This means one of
two things has to happen: I either have to add an integer column to
the messages table for every one of the tag categories (the number of
categories is likely to grow up to 30+.) Or I have to add a table for
these count numbers and do a separate activerecord lookup for each one
of the categories for each of the messages on the page (which really
adds up!)
To give you an example, here’s how one message might look:
What is the best way to model this for the best performance? Remember
that there could be dozens of other tags that are not displayed
(because they are 0, or for other reasons.)
Is there any way to store a hash (or, if no other way an array of key
value pairs) in an active record class?
I have a few questions about how well RoR performs under various
‘irregular’ circumstances. First, how quickly does rails work when
there are potentially lots of embedded ruby expressions (hundreds) per
page? Also, how well does ruby do when there are perhaps hundreds of
database reads per page?
However, I have another question about how the caching actually
works. Does it cache the html output of the fragment it surrounds and
just serve that up to anyone who requests that fragment each time? If
so, is it possible to cache an ActiveRecord object and then render it
in a different way depending on the user who is currently logged in?
For instance, every user would key off the same cached copy of the
result (until the row changed) but it would be rendered differently
depending on various conditions. Can Rails’ caching accomplish
something like this?
result (until the row changed) but it would be rendered differently
depending on various conditions. Can Rails’ caching accomplish
something like this?
Yes. Read the Rails Guide on caching, there’s a section labeled Action
Caching, which can do what you want.
Walter
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.