Chamnap Chhorn

Ruby, Rails, and JavaScript Developer

Active_record_uuid 0.2.0 Is Released

| Comments

After releasing version 0.1.0, I get the feeling I need to add one more feature to this gem, the ability to configure in global and per model. Actually, it’s a small change, but I haven’t had enough time to do it. Now, it’s complete.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# config/initializers/active_record_uuid_config.rb
ActiveRecordUuid.configure do
  column      :uuid
  primary_key true
  association false
  store_as    :binary
end

# models
class People < ActiveRecord::Base
  has_uuid :association => true
  has_many :comments
end

class Article < ActiveRecord::Base
  has_uuid
end

In the example above, it will merge the global configuration options with the passed in options in has_uuid.

There’s a config generator that generates the default configuration file into config/initializers directory. Run the following generator command, then edit the generated file.

1
  $ rails g active_record_uuid:config

Comments