PLEASE NOTE This project is abandoned and left here in case its of use to others. Please feel free to start and publish your own fork with your own customizations.
Boost your Rails ActiveRecord Query core fitness with this workout plan. For the home, office, and gym.
Rails ActiveRecord Aerobics is a collection of exercises to help you learn, practice, and master Rails ActiveRecord Querying.
This is for all Rails developers of all experience levels. Consult a medical practitioner before beginning a new fitness program.
The exercises build on each other to strengthen your query skills bit-by-bit. Take them as fast or as slow as you like.
Use common sense and deduction to figure out what code is being asked for, then write it, wherever you encounter YOUR_CODE_HERE
in the exercises.
If you want a playground of data to experiment and practice with then run bin/rake db:seed
, followed by bin/rails c
, and then try out a few queries with the provided data. e.g. Category.where("name like '%e%'").count
and Product.all
.
git clone [email protected]:eliotsykes/rails-activerecord-aerobics.git
cd rails-activerecord-aerobics
bundle install
bundle binstubs rspec-core
bin/rake db:migrate
to setup the dbbin/rake gen
to generate exercises inspec/exercises
bin/rake go
to begin your aerobics workout- The exercise specs in
spec/exercises
will fail. Go in and edit them where it says YOUR_CODE_HERE to make them pass. - Repeat steps 7 and 8 until all your exercises pass.
- Feel the burn.
From find
to advanced queries using join
, includes
. Everything covered in Rails ActiveRecord Querying guide and anything else useful not mentioned. Comb through API docs.
Don't be too abstract with models, favour classes developers might encounter in a day job.
First x specs each deal with one topic and a set of tightly related drills using a mix of model families:
- a01_find_spec
- a02_find_by_spec
- a03_find_by_*_spec
- a04_where_spec
- ???
- a09_joins_spec
- a10_basic_sql_spec
- a11_advanced_sql_spec
(remember to write exercises for ActiveRecord::Calculations)
Last y specs focus on one family of models each, with exercises that make use of all previously learned skills. Start off with a few finds, then some find_bys, and work up to joins and more, all in one spec file for each model family.
- b01_book_spec
- b02_invoice_spec
- b03_credit_card_spec
- b04_customer_spec
- b05_product_spec
- b06_content_spec
- b07_user_spec
- b08_money/account/finance_spec
- ???
- Eliot Sykes https://eliotsykes.com/
- Your name here - Contributions welcome!
bin/rspec plans