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

Version Path
counter_culture-2.2.2 spec/models/another_post.rb
counter_culture-2.2.1 spec/models/another_post.rb
counter_culture-2.2.0 spec/models/another_post.rb
counter_culture-2.1.4 spec/models/another_post.rb
counter_culture-2.1.3 spec/models/another_post.rb
counter_culture-2.1.2 spec/models/another_post.rb
counter_culture-2.1.1 spec/models/another_post.rb
counter_culture-2.1.0 spec/models/another_post.rb
counter_culture-2.0.1 spec/models/another_post.rb
counter_culture-2.0.0 spec/models/another_post.rb
counter_culture-1.12.0 spec/models/another_post.rb
counter_culture-1.11.0 spec/models/another_post.rb
counter_culture-1.10.0 spec/models/another_post.rb
counter_culture-1.9.2 spec/models/another_post.rb
counter_culture-1.9.1 spec/models/another_post.rb
counter_culture-1.9.0 spec/models/another_post.rb
counter_culture-1.8.2 spec/models/another_post.rb
counter_culture-1.8.1 spec/models/another_post.rb
counter_culture-1.8.0 spec/models/another_post.rb
counter_culture-1.7.0 spec/models/another_post.rb