Providing a flexible alias for column names in ActiveRecord.
- Add utusemi in the
Gemfile
:
gem 'utusemi'
- Download and install by running:
bundle install
- Create a file named
utusemi.rb
inconfig/initializers
and add column names in this file.
Utusemi.configure do
map :sample do
name :first_name
end
end
- Use
utusemi
method.
irb> User.utusemi(:sample).where(name: 'John')
SELECT "users".* FROM "users" WHERE "users"."first_name" = 'John'
- Ruby on Rails 3.2, 4.1
- Ruby 2.1
To set up a development environment, simply do:
bundle install
bundle exec rake db:create
bundle exec rake db:migrate
bundle exec rake # run the test suite