Sha256: 88a7dca0cdc3a87a445602de2c2a4d9bd0c962df9c927669f61299bd628adf44
Contents?: true
Size: 777 Bytes
Versions: 3
Compression:
Stored size: 777 Bytes
Contents
Adds support for transparent enums to ActiveRecord. Adds a belongs_to_enum to ActiveRecord that takes an array of possible values. Usage --------- Use in Rails 3 app. Add to bundler: gem "belongs_to_enum" Tests --------- Uses rspec for testing. Run tests with rspec spec/* Todo --------- * Add scopes Example --------- Usage: In models: scope :admin, where(:role_id => User::Role.admin) In views: =f.select(:role, User::Role.pretty_items) -User::Role.each do |role_title, role_id| #{role_title} (#{role_id}) Classes: class User < ActiveRecord::Base belongs_to_enum :role, [:normal, :admin, :superadmin, :suspended] end Database Schema: create_table :users do |t| t.float :role_id end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
belongs_to_enum-0.4.0 | README |
belongs_to_enum-0.3.1 | README |
belongs_to_enum-0.3 | README |