Read the Rails Guide about Active Record migrations Understand why we never use models in migrations. Checkout the repository Project Hero and read through some migrations in db/migrate. Find...
...files in the db/migrate folder. Read and understand How to write complex migrations in Rails Discuss with your mentor Instead of migrations, could we simply log into the production server...
Rails is our web framework. Goals Be able to write a simple Rails application. Understand how Rails talks to the database (ActiveRecord) What is a model? How are records retrieved...
...has_many, has_many :through Gain an understanding of the structure of a basic Rails app Routes Controllers Generate a controller using Rails scaffolding Write your own controller Views
While working on a Rails application, your code base will grow a collection of different file types including: Ruby (business logic) HTML fragments (layouts and views) CSS/Sass/SCSS (styles) JavaScript (client...
...files which are often summed up as assets. You might already have noticed that Rails modifies those assets before delivering them to the client. For example, you'll never see...
...a cookie's "secure" flag do? Is it still relevant with HSTS? Look at Rails' API for managing cookies How do you set and delete cookies? What are signed cookies...
What are encrypted cookies and how do they work? Learn about Rails sessions (which are not the same as 'session cookies') Learn about the SameSite cookie attribute...
...Mailer Basics and Previews Chapter "Task H1: Sending Mail" from Agile Web Development with Rails 7.2 (in our library) Ensure that the receiving e-mail is valid Using the Truemail...
Ensure that development and staging are not sending out e-mails by accident Rails: How to write custom email interceptors Check if you have a local mail server listening...
...security issues in web application, often known as "OWASP Top 10": https://owasp.org/www-project-top-ten/ Rails security Read the following sections from the Rails security guide. For each section you should...
...understand the security issue and what tools Rails gives you to address it. Cross-Site Request Forgery (CSRF) SQL Injection Cross-Site Scripting (XSS) Content Security Policy Also A reasonable...
Resources Rails Guide: Internationalization API Guide to localizing a Rails application Locale-aware helpers in ActionView::Helpers::NumberHelper Accept-Language HTTP header. Can be parsed with a gem like...
Standard Rails translations The default strings used by Rails can be found in the rails-i18n repository. When we start a new project we often copy the German/English locale...
...Nested example groups before(:each) after(:each) let subject RSpec.configure, config.before, config.after Resources Everyday Rails Testing with RSpec (in our library), chapter 8 (Keeping Specs DRY) Note: Please refer to...
...render_template() matcher that helps with test above. To get this matcher, add a gem rails-controller-testing. Tip If you place your spec file in spec/requests you don't...
...the behavior, not the implementation" means. Resources Chapter "The value of tests" from Growing Rails Applications in Practice (in our library) Everyday Rails Testing with RSpec (in our library)
...of today, the Rails 7 version of this book is not fully complete. Until then, we have to work with two versions. Concentrate on chapters: 1 (Introduction), 2 (Setting up...
...a named scope like Post.active and use that. Learn Resources Active Record Query Interface Rails Database Best Practices ActiveRecord: Specifying conditions on an associated table Preload, Eagerload, Includes and Joins...
...Battling n+1 Queries in Rails Tips Preventing scopes from loading A scope like User.where(email: 'foo@bar.com') does not make an SQL query. It simply returns a scope object for...
Note that when your app is a web app, the console running your rails server will pause the server and show the debugging console. Your browser will "hang" while...
If you need to debug code that is part of a gem like rails, just (temporarily) add a puts or debugger statement to its source files. Ruby is an...
Understand how nested attributes appear in the params. See how the Rails form helpers encode the names of nested inputs. Understand how the record and all of its nested...
...saved in a transaction. That means the entire structure is saved or not. Resources Rails Guide: Nested forms Nested Forms in Rails Popular mistakes when using nested forms When aggregating...
...for Ruby 3.3: A nice API for the official Ruby standard library Ruby on Rails Since you will use Rails more than any other gem, you will always want its...
...documentation to be close: Rails API Rails guides ActiveSupport ActiveSupport extends core classes in Ruby. We are so used to having ActiveSupport around that we don’t even think of...
Basic validations Read the Rails Guide on ActiveRecord Validations. You should have an overview which kinds of validations are built into Rails. Also read Testing ActiveRecord validations with RSpec.
...colored red. In addition, an invalid field control should have a red border. Tip Rails adds an extra element around invalid inputs to help with styling. Inspect an invalid field...
...piece, but it should be tidy and clear. If you have generated styles from Rails scaffolding, delete them all. They don't look nice and we do not use them...
...remove it and build your own styles from scratch. Tip Up until version 6, Rails understands Sass out of the box. No need to install additional software. Your MovieDB uses...
...BEM, block-by-block. Read Read the chapter "Taming Stylesheets" from our book Growing Rails Applications in Practice (in our library). Talk with a colleague about the reasons for the...
...a good BEM structure in the DOM tree of these websites: https://makandra.de/ https://railslts.com/ https://www.aitiraum.de/ Practice: Cards In a new project, try to layout the style of...
...stack of tools. Start this card by skimming over the linked resource. Discussion Growing Rails applications in practice Read the following chapters from our book Growing Rails Applications in Practice...
...On following fashions Surviving the upgrade pace of Rails Owning your stack Discuss each chapter with your mentor. The Swinging Pendulum The XKCD about the sandboxing cycle is quite on...
...is rake good for? Take a look at some of the Rake tasks that Rails gives you (rake -T within a Rails project) Find the code that defines the rake...
...stats task in the Rails gems What are some ways how a Rake task can execute another task? What does it mean if a Rake task "depends" on another task...
...for every little thing. Jasmine is a purely client-side tool. It cannot ask Rails to render a view or access the database. Any HTTP calls must be mocked.
Tip Create the required DOM directly from your Jasmine spec. You cannot ask Rails to render a view. You can use Element#dispatchEvent() to emit events on a DOM...
...you're not familiar with the pattern, read or re-read "New rules for Rails" from Growing Rails Applications in Practice (in our library) How to navigate between indexes, show...
...feature-binaries commit id: "docs" commit id: "add binaries" type: HIGHLIGHT commit id: "init rails" You are now asked to split up the add binaries commit to one commit per...
...id: "echo binary" type: HIGHLIGHT commit id: "curl binary" type: HIGHLIGHT commit id: "init rails" Exercise 3: Rebase onto a diverged feature branch with merge conflicts %%{init: { 'gitGraph': { 'mainBranchName': 'master...
Learn about Method#source_location. Look up a method like save! in the Rails API docs. The result should have a link to the source location on GitHub.
...monkey patches. When you add or change an initializer you need to restart your Rails server or console for the changes to be picked up. Only changes in app are...
Read (or re-read) the following chapters from our book Growing Rails Applications in Practice (it’s in our library): New rules for Rails Beautiful controllers Relearning ActiveRecord
...popular authentication libraries like clearance or devise for this task. Learn Read the article Rails Authentication from Scratch You don't need to do write any code, but you should...
...you have access to the database? Can you sign out a user using the Rails console? If someone can read our network traffic, can he see a user's password...