Arelable

Welcome to Arelable gem!

You are thinking that it is not cool to write raw SQL in Rails, aren't you?

Then just use this gem. Arelable is a simple SQL wrappers for Rails to help you not to write raw SQL, like Arel.

*Arel is not recommended to be used in your application logics because it is private method of Rails.

Installation

Add this line to your application's Gemfile:

gem 'arelable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install arelable

Usage

You need to include Arelable in your target Model like below.

class User < ActiveRecord::Base
  include Arelable
end

gt

User.gt(:age, 35)
# => SELECT COUNT(*) FROM `users` WHERE (age > 35)

gteq

User.geteq(:age, 35)
# => SELECT COUNT(*) FROM `users` WHERE (age >= 35)

lt

User.lt(:age, 35)
# => SELECT COUNT(*) FROM `users` WHERE (age < 35)

lteq

User.lteq(:age, 35)
# => SELECT COUNT(*) FROM `users` WHERE (age <= 35)

bw

User.bw(:age, [35, 40])
# => SELECT COUNT(*) FROM `users` WHERE (age BETWEEN 35 AND 40)

matches

User.matches(:name, "Bo")
# => SELECT COUNT(*) FROM `users` WHERE (first_name LIKE '%Bo%')

Development

After checking out the repo, run bin/setup to install dependencies.

Then, create database as following.

$ mysql -u root -p
$ CREATE DATABASE areable_test CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

Then, run bin/spec to run the tests.

You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/arelable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Arelable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.