...Basics and Previews Chapter "Task H1: Sending Confirmation Emails" from Agile Web Development with Rails (in our library) Ensure that the receiving e-mail is valid Using the Truemail gem...
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...
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...
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...
...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...
...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)
...Movie.search() and the new UI. Follow the advice from the "Testing" chapter from Growing Rails Applications in Practice: RSpec feature tests for the most common "happy path" RSpec unit tests...
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...
...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...
...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...
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...
...Ruby projects. These projects use a large number of different versions for Ruby, Rails and many gems. To be able to switch between projects easily, we must control every dependency...
...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...
Adopting legacy Rails apps Talk to your mentor about how we're approaching applications that are either old or abandoned by a different team earlier: Add E2E tests for the...
...Best practices for writing code comments Read the following chapters from our book Growing Rails Application in Practice: Dealing with fat models Extracting service objects Discuss with your mentor what...
...create only the records needed for the test. Learn Factories, not fixtures By default Rails uses global fixtures for its tests. This is a giant world of example data that...
...other gems in the past, but they all work in the same way. Watch Railscasts PRO #158 Factories not Fixtures (revised) for an introduction to factories in general and FactoryBot...
...README for the carrierwave gem Read about Common mistakes when storing file uploads with Rails Carrierwave: How to attach files in tests Carrierwave: Built-in RSpec matchers CarrierWave: Processing images...
...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...
Watch Solving bizarre authorization requirements with Rails Read the Consul README Read the assignable_values README Understand how Consul and assignable_values can be used to implement arbitrary authorization...
...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...
...to understand what middlewares in Rack are good for. Rack Start with these articles: Rails on Rack Introduction to Rack Middleware Short Screencast to a sample Middleware
...answer the following questions: What is Rack? How does Rack relate to Ruby on Rails? What is Rack middleware? What are some advantages of implementing functionality as a middleware as...
...we're using building some of our sites using static site generators instead of Rails. You should talk about: Ease of development Security issues and maintenance costs Read through the...
What can't it do? What parts do you know from Rails? Practice Checkout the repo for the makandra blog Start the preview server Make some changes...
...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...