Skip to content

Commit

Permalink
Work around Rails error that won't read a model fetched from cache in…
Browse files Browse the repository at this point in the history
… dev mode properly
  • Loading branch information
just3ws committed Nov 12, 2014
1 parent 370a227 commit b900166
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/protip.rb
Expand Up @@ -316,9 +316,10 @@ def already_created_a_protip_for(url)
end

def valid_reviewers
User # Hack to force loading User model before it gets read from cache and explodes in dev.
Rails.cache.fetch('valid_protip_reviewers', expires_in: 1.month) do
if ENV['REVIEWERS']
User.where(username: YAML.load(ENV['REVIEWERS'])).all
User.where(username: YAML.load(ENV['REVIEWERS'])).to_a
else
[]
end
Expand Down

0 comments on commit b900166

Please sign in to comment.