Notes posted by sfusion
RSS feed
0 thanks
Validations
out of the box touch will run with validations

0 thanks
Create new Hash as subset of another a different way
or
only keys
old_hash = { :a => 'A', :b => 'B', :c => 'C', :d => 'D', :e => 'E', :f => 'F' } only_keys = [ :a, :c, :f ] new_hash = old_hash.delete_if { |k, v| !only_keys.include? k }
only values
old_hash = { :a => 'A', :b => 'B', :c => 'C', :d => 'D', :e => 'E', :f => 'F' } only_values = [ 'A', 'D', 'G' ] new_hash = old_hash.delete_if { |k, v| !only_values.include? v }
there are many ways to skin a cat :)

1 thank

0 thanks
Re: Find random record
How about if you wanted to find a random set of records instead of a singular record, what would be the best way?
Thank you