
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
The UUIDParameter
module provides support for UUIDs in ActiveRecord
models.
It takes care of generating (if one was not provided), validating, and keeping
this UUID intact, protecting the :uuid
field from being changed once set.
Models including the UUIDParameter
module will:
:uuid
rather than their :id
(primary key) for URLs.uuid
column): saving the
model with nil
values will provide a new UUID.:create
if one is not set.:to_param
to provide the UUID instead of the primary key.#reset_uuid!
to bypass this, or
use SQL directly in the database. (See #1)Translations are in progress (See #2): specs are now passing thanks to a hack.
To add a new translation, please edit or create the corresponding file in
config/locale
.
Add a uuid
column to your model if it does not have one already:
$ rails g migration AddUuidColumnToUser uuid:string{36}
$ rails db:migrate
If you're using Postgres, you should use the native uuid
type instead:
$ rails g migration AddUuidColumnToUser uuid:uuid
$ rails db:migrate
Then, simply include the module in your model:
class User < ApplicationRecord
include UUIDParameter
end
# u = User.create # Generates a new UUID
# u.id # => 123 (does not change primary key)
# u.uuid # => '8bb27724-7439-4965-9598-883419179b21'
# u.to_param # => '8bb27724-7439-4965-9598-883419179b21'
# u.uuid = SecureRandom.uuid
# u.save # Silently ignores changes to :uuid
# u.reload # Instead, it restores the original:
# u.uuid # => '8bb27724-7439-4965-9598-883419179b21'
Add this line to your application's Gemfile:
gem 'uuid_parameter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install uuid_parameter
Bug reports and pull requests are welcome on Gitlab at https://gitlab.com/incommon.cc/uuid_parameter.
See ChangeLog and commit messages.
The Github repository is a mirror to facilitate integration with other Rails development, but I don't like Microsoft, and never will. They may show the face they like, they come from enemity and, as far as I'm concerned, will remain there.
After checking out the repo, run bin/setup
to install dependencies.
Run specifications with bundle exec rake
.
To install this gem onto your local machine, run bundle exec rake install
. To
release a new version, update the version number in version.rb
, and then run
bundle exec rake release
, which will create a git tag for the version, push
git commits and tags, and push the .gem
file to
rubygems.org.
See bundle exec rake -T
for more options.
You can now use bin/console
to get a nice Pry
console for development.
This gem is free software under the same license terms as Rails.
FAQs
Unknown package
We found that uuid_parameter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.