Ruby gem that provides arel-backed virtual attributes for ActiveRecord models.
source /opt/homebrew/share/chruby/chruby.sh && chruby 4.0 && bundle install # first time only
source /opt/homebrew/share/chruby/chruby.sh && chruby 4.0 && bundle exec rspec # all tests
source /opt/homebrew/share/chruby/chruby.sh && chruby 4.0 && bundle exec rspec -e "description" # single test
source /opt/homebrew/share/chruby/chruby.sh && chruby 4.0 && bundle exec rspec spec/ancestry_spec.rb # ancestry tests onlyDefault is sqlite3. Set DB env var to switch:
DB=sqlite3(default)DB=pgfor postgresDB=trilogyfor mysql
- Always write tests — do NOT use
ruby -eone-off scripts. The test environment sets up models and databases correctly; standalone scripts fail with anonymous class errors. - Use
bundle exec rspec -e "description"to run a specific test. - For Rails monkey-patches in
match_association.rbandarel_attribute.rb:- Put the Rails version and source file:line in a comment above each overridden method
- Wrap changes in
# CHANGED/# / CHANGEDblocks with the original line commented out - This makes it easy to diff against upstream Rails when upgrading
ArelAttribute::Base— included into ActiveRecord models, providesarel_attributeArelAttribute::TableProxy— wrapsArel::Tableto resolve virtual attributes via arel blocks in WHERE/ORDER/SELECTArelAttribute::ArelAggregate— aggregate arel attributes (arel_total,arel_sum, etc.) using correlated subqueriesArel::Nodes::ArelAttribute— custom arel node that expands arel blocks at SQL generation time