kenn / enum_accessor Goto Github PK
View Code? Open in Web Editor NEWEnumAccessor - Simple enum fields for ActiveRecord
License: MIT License
EnumAccessor - Simple enum fields for ActiveRecord
License: MIT License
I like this little gem.
I tried to use it but I would like to allow a null value (with means it hasn't yet or shouldn't been set). The problem is that enum_accessor triggers an 'is not included in the list' validation error.
Solved my problem by using the option: validation_options: {allow_nil: true}
which IS documented...
User.where.not(approval_status: :approved)
Makes the following SQL (the problem is :approved is changed to NULL)
User Load (0.4ms) SELECT
users.* FROM
usersWHERE (
users.
approval_status!= NULL)
Given
class ShipmentCharge < Charge #STI
enum_accessor :container_type, ['20GP','20HC','40GP','40HC','9BOX','4BOX', 'LCL', 'OTHER']
end
I get the following problem with this:
Symbols vs string vs leading digits
c.container_type= '20GP'
c.container_type # => :"20GP" Beurk!
Maybe an option not to use symbols would be great.
Hi there,
Has any solution to get raw value of enums instead string value when query collection of active record objects ? I know we can get raw value by _raw each object but how to get this raw
value when select ?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.