...Transactions and database setup, and Drivers (rack_test vs. Selenium) 📄 Feature specs in rspec-rails — how a feature spec is set up, and how js: true switches an example to...

...set of boolean flags. You can implement a state machine in plain Ruby and Rails: a state column, transition methods that only allow valid transitions, and callbacks on transition.

...can implement the same with a gem like rails_state_machine and explain what the gem adds over the hand-written version. You can make validations depend on the record...

...or an explanation for anything here, tailored to what you already know. Just ask. 📄 Rails Guide: the :dependent option — what each option does when the parent goes away 📄 assignable_values...

...with before/after examples from our projects 📘 The chapter "Taming Stylesheets" from our book Growing Rails Applications in Practice (in our library) — why CSS rots and how blocks fix it

...you recognize it in other projects 🎮 Inspect the DOM of https://makandra.de/, https://railslts.com/ and https://www.aitiraum.de/ — examples of a good BEM structure Cutting block boundaries Deciding what becomes...

JavaScript code can access and manipulate the browser's DOM tree. Using JavaScript we can add interactive behavior to our...

...check our library) 📄 DSLs in the wild: factory_bot's partial factory definitions and Rails' Engine configuration — read how libraries you use every day are built on these techniques

...gem used in the exercise: paginate, will_paginate view helper, customizing the rendered links 📄 Rails Guide: Active Record Query Interface — limit and offset — what pagination does in SQL

...explanation for anything here, tailored to what you already know. Just ask. 📄 Speeding up Rails with Memoization 📄 4 Simple Memoization Patterns in Ruby (And One Gem) — including why ||= fails for...

website_sizer = WebsiteSizer.new website_sizer.size_of('https://makandra.com') # => 27448 website_sizer.size_of('https://railslts.com') # => 2145364 You can use any library to perform the actual HTTP request. The class should...

...often need to move data between the client (HTML, Javascript) and the server (Ruby, Rails). Step 1: Moving HTML snippets Add a find-as-you-type search to MovieDB. Above...

Best results in other decks

Note: Modern Rails has two build pipelines, the asset pipeline (or "Sprockets") and Webpacker. The principles below apply for both, but the examples shown are for Sprockets.

...request these assets again and again on every request. There is no magic in Rails that gives you automatic caching for assets. In fact, if you haven't been paying...

Every Rails response has a default ETag header. In theory this would enable caching for multiple requests to the same resource. Unfortunately the default ETags produced by Rails are effectively...

...random, meaning they can never match a future request. Understanding ETags When your Rails app responds with ETag headers, future requests to the same URL can be answered with an...

Search in all decks