Ruby on Rails Tuesday, September 1, 2015

On 1 September 2015 at 15:41, Elizabeth McGurty <emcgurty2@gmail.com> wrote:
> And I am also super confused as to the notion of 'memorising'. What does
> that mean? Kids memorise the alphabet and times tables, what does that
> metaphor mean in terms of Ruby and Ruby on Rails? Memorising is a process of
> repeatedly iterating through a series that must eventually be held in one's
> memory. Does Rails have some neural process of educating itself in neural
> memorising?

The test filter (which is not actually called that of course, it has a
name meaningful in the context of my application) does a fair amount
of db lookup, based on the request params, and comes up with a true or
false answer. My mod is, in the test filter, to test a class variable
(lets call it @test_answer) and if it is nil then to run the db
lookups, caculate the answer true or false, save it in @test_answer
and return that value. If it is not nil then I just return the value.
The result is that the first time it runs it does the lookup, the
second time it just returns the answer

In practice that just turns into something like
def test?
@test_answer ||= do_the_lookup_and_calcs()
end

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv9j5L%2Bz26MR6eXsXUrfTWh1i6J%2Bga0A-YJLZMfgXDZUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment