...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...

...what you already know. Just ask. 📘 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 files that can be loaded individually from your application layout. By default your Rails application has a single entrypoint application.js, which should import all other files.

...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

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...

...must be translated: Screens, mailer templates, PDF templates, helpers, sometimes models. Use the native Rails I18n API. Avoid Gettext if possible. Native I18n has good integration with Rails (you already...

...Rails framework can be overridden in locale dictionaries (e.g. config/locales/de.yml). There's an awesome gem rails-i18n that gives you default dictionaries for many languages. Note that even though all...

Search in all decks