Coder Social home page Coder Social logo

eliotsykes / rails-activerecord-aerobics Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 4.0 59 KB

[UNMAINTAINED] Boost your Rails ActiveRecord Query core fitness with this workout plan. A+ abs or your money back.

License: MIT License

Ruby 90.62% CSS 1.17% HTML 8.21%

rails-activerecord-aerobics's Introduction

[UNMAINTAINED] Rails ActiveRecord Aerobics

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.

How do I run the exercises?

  1. git clone [email protected]:eliotsykes/rails-activerecord-aerobics.git
  2. cd rails-activerecord-aerobics
  3. bundle install
  4. bundle binstubs rspec-core
  5. bin/rake db:migrate to setup the db
  6. bin/rake gen to generate exercises in spec/exercises
  7. bin/rake go to begin your aerobics workout
  8. The exercise specs in spec/exercises will fail. Go in and edit them where it says YOUR_CODE_HERE to make them pass.
  9. Repeat steps 7 and 8 until all your exercises pass.
  10. Feel the burn.

Draft Workout Plans (work in progress)

What to practice?

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.

How to structure the specs?

First x specs each deal with one topic and a set of tightly related drills using a mix of model families:

  1. a01_find_spec
  2. a02_find_by_spec
  3. a03_find_by_*_spec
  4. a04_where_spec
  5. ???
  6. a09_joins_spec
  7. a10_basic_sql_spec
  8. 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.

  1. b01_book_spec
  2. b02_invoice_spec
  3. b03_credit_card_spec
  4. b04_customer_spec
  5. b05_product_spec
  6. b06_content_spec
  7. b07_user_spec
  8. b08_money/account/finance_spec
  9. ???

Contributors

Contributors FAQ

How to run workout plan specs?

bin/rspec plans

rails-activerecord-aerobics's People

Contributors

eliotsykes avatar

Stargazers

Tabish Iqbal avatar  avatar Chris Kibble avatar

Watchers

 avatar James Cloos avatar  avatar

rails-activerecord-aerobics's Issues

More free-form structure for (some) exercise challenges

Rather than always asking the developer to fill in part of a line, instead ask them to fill in the 1+ lines with some guidance on what the solution contains, e.g.:

# CHALLENGE
# Write an ActiveRecord query that returns the 5 most recently
# created products with names longer than 15 chars and assigns
# them to a variable named "products". The query
# should also populate `categories` for each product at the same
# time. You can use either the `include`, `preload`,  or 
# `eager_load` methods to populate the product categories.
products = Product.where("LENGTH(name) > 15")
  .order(created_at: :desc).limit(5).include(:categories)#hide
# YOUR_CODE_HERE#show

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.