Commit c6569df23cfe34d3c5131e05ac6560df6771e6f4
1 parent
b372312b
Exists in
master
and in
1 other branch
memoization
Showing
1 changed file
with
3 additions
and
0 deletions
Show diff stats
app/models/question.rb
| 1 | 1 | class Question < ActiveRecord::Base |
| 2 | 2 | require 'set' |
| 3 | + extend ActiveSupport::Memoizable | |
| 4 | + | |
| 3 | 5 | belongs_to :creator, :class_name => "Visitor", :foreign_key => "creator_id" |
| 4 | 6 | belongs_to :site, :class_name => "User", :foreign_key => "site_id" |
| 5 | 7 | |
| ... | ... | @@ -29,6 +31,7 @@ class Question < ActiveRecord::Base |
| 29 | 31 | choice_id_array = distinct_array_of_choice_ids(rank) |
| 30 | 32 | @p = prompts.find_or_create_by_left_choice_id_and_right_choice_id(choice_id_array[0], choice_id_array[1]) |
| 31 | 33 | end |
| 34 | + memoize :picked_prompt | |
| 32 | 35 | |
| 33 | 36 | def distinct_array_of_choice_ids(rank = 2, only_active = true) |
| 34 | 37 | begin | ... | ... |