Permalink
Browse files

Modify SQL in RecentView factory to support MySQL

  • Loading branch information...
rlue authored and Ryan Lue committed Sep 11, 2018
1 parent d51d222 commit 3c1e8ba1236679f14fc2df2d025f9803c15cf4e7
Showing with 8 additions and 1 deletion.
  1. +8 −1 spec/factories/recent_view.rb
@@ -9,7 +9,14 @@
# select a random record of the given object class
o_id do
type.to_s.camelcase.constantize.order('RANDOM()').first.id
random_function = case ActiveRecord::Base.connection_config[:adapter]
when 'mysql2'
'RAND'
when 'postgresql'
'RANDOM'
end
type.to_s.camelcase.constantize.order("#{random_function}()").first.id
end
# assign to an existing user, if possible

0 comments on commit 3c1e8ba

Please sign in to comment.