Sha256: 89d1001ac8bbaa27ba2f93186f8e86e6b3d811a1e80d4fea9fd4d106f7c52c05
Contents?: true
Size: 384 Bytes
Versions: 41
Compression:
Stored size: 384 Bytes
Contents
class AnotherPost < ActiveRecord::Base has_many :comments, class_name: 'AnotherPostComment', foreign_key: 'another_post_id', primary_key: 'another_id' before_save :assign_another_id, :if => :new_record? private def assign_another_id loop do self.another_id = Random.rand(65535) break unless self.class.where(another_id: another_id).exists? end end end
Version data entries
41 entries across 41 versions & 1 rubygems