Sha256: ed2be0aeb10b9fcaa0e7c5a85253d172da26c4682fa661dc075bf02bded6aa91

Contents?: true

Size: 1.48 KB

Versions: 8

Compression:

Stored size: 1.48 KB

Contents

# SqlEnum

Enables usage of native sql enums with ActiveRecord

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'sql_enum'
```

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install sql_enum

## Usage

### Migrations

Use a part of table definition:
```ruby
class CreateUsers < ActiveRecord::Migration[5.1]
  def change
    create_table :users do |t|
      t.enum :status, limit: [:active, :pending, :inactive], default: :active

      t.timestamps
    end
  end
end
```

Or add an enum column:
```ruby
add_column :users, :status, :enum, limit: [:active, :pending, :inactive], default: :active
```

### ActiveRecord

```ruby
class User < ActiveRecord::Base
  sql_enum :status
end
```

## TODO

* Enable passing `null` argument

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/1debit/sql_enum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.

## License

Inspiration from [native_enum](https://github.com/iangreenleaf/native_enum)

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

## Code of Conduct

Everyone interacting in the SqlEnum project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/1debit/sql_enum/blob/master/CODE_OF_CONDUCT.md).

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sql_enum-0.2.2 README.md
sql_enum-0.2.1 README.md
sql_enum-0.1.18 README.md
sql_enum-0.1.17 README.md
sql_enum-0.1.16 README.md
sql_enum-0.1.15 README.md
sql_enum-0.1.14 README.md
sql_enum-0.1.13 README.md