Module: ActiveRecord::RandomID
- Included in:
- Base
- Defined in:
- lib/vex/active_record/random_id.rb
Defined Under Namespace
Modules: Generator
Instance Method Summary collapse
- #with_random_column(column, generator = :integer) ⇒ Object
- #with_random_id(generator = :integer) ⇒ Object
Instance Method Details
#with_random_column(column, generator = :integer) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/vex/active_record/random_id.rb', line 19 def with_random_column(column, generator = :integer) before_validation do |rec| next if rec.send(column) rec.send "#{column}=", ActiveRecord::RandomID::Generator.send(generator) end end |
#with_random_id(generator = :integer) ⇒ Object
26 27 28 |
# File 'lib/vex/active_record/random_id.rb', line 26 def with_random_id(generator = :integer) with_random_column primary_key, generator end |