Sha256: f113148a1450aab0d8d7d68d5d107d7c40c1a39555ae14e6f4b807ea6459443e
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
require 'active_record' require 'ransack' module Surikat class BaseModel < ActiveRecord::Base ActiveRecord::Base.establish_connection(Surikat.config.db) self.abstract_class = true # Used when running tests def self.create_random create random_params end def self.random_params params = {} columns.each do |col| next if ['id', 'created_at', 'updated_at'].include?(col.name) params[col.name] = case col.type.to_s when 'string' "Some String #{SecureRandom.hex(4)}" when 'float', 'integer' rand(100) when 'boolean' [true, false].sample end end params end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
surikat-0.2.4 | lib/surikat/base_model.rb |
surikat-0.2.3 | lib/surikat/base_model.rb |