Socket
Book a DemoInstallSign in
Socket

active_record-humanized_enum

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active_record-humanized_enum

0.2.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

ActiveRecord Humanized Enum (I18n)

Easily translate your Active Record's enums.

Installation

Include to your Gemfile

gem 'active_record-humanized_enum'

Usage

ActiveRecord integration

The installation automatically self-includes in the ActiveRecord::Base.

How to use

  • Call the enum macro method just like you already do:
class User
  enum status: [:enabled, :disabled]
end
  • Translate the enums in your YML translation files:
pt-BR:
  activerecord:
    attributes:
      user:
        status: Estado
        statuses:
          enabled: Ativo
          disabled: Inativo
  • Will be available the following methods:
User.humanized_status(:enabled) # Ativo
User.humanized_status(:disabled) # Inativo

user = User.first
puts user.status # enabled
puts user.humanized_status # Ativo

user.status = :disabled
puts user.humanized_status # Inativo
  • Integration with ActiveAdmin

Maintainer

Dhyego Fernando

FAQs

Package last updated on 28 Sep 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.