Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

activerecord_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

activerecord_humanized_enum

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ActiveRecord Humanized Enum (I18n)

Easily translate your Active Record's enums.

Installation

Include to your Gemfile

gem 'activerecord_humanized_enum', require: 'active_record/humanized_enum'

Usage

ActiveRecord integration

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

How to use

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

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

user.status = :disabled
puts user.humanized_status # Inativo

Maintainer

Dhyego Fernando

FAQs

Package last updated on 06 Oct 2017

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc