Understand that an expression like User.where(email: 'foo@bar.com') does not make an SQL query. It simply returns a scope object for further chaining with #where, #order, etc.

...will make an SQL query when you use them like an array, e.g. by iterating over them with #each. This may cause the scope to accidentally load its results prematurely...

makandra Curriculum

Instead of migrations, could we simply log into the production server's SQL console and alter tables there whenever we need a change? How do we need to...

...existing records. Write this migration in multiple styles: Embedding ActiveRecord models into your migration SQL statements (update "UPDATE actors SET...

makandra Curriculum

...should this not be an instance method? You can implement the search in either SQL or Ruby The form_for helper is not helpful for the search form above the...

makandra Curriculum

...in the rails console and it will log the exact database interaction with related sql commands and its result. Before you know where to debug, you will often find yourself...

...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 default Content Security Policy...

Best results in other decks

...behavior and implementation. PostgreSQL Timeout Type: statement_timeout Scope: Applies to all types of SQL statements (SELECT, INSERT, UPDATE, DELETE). Units: Can be specified in various time units (milliseconds, seconds...

...to the timeout (ERROR: canceling statement due to statement timeout (PG::QueryCanceled)). If multiple SQL statements appear in a single simple-query message, the timeout is applied to each statement...

When debugging slow SQL queries, it’s helpful to understand the database engine's query plan. Whenever you execute a declarative SQL query, the database generates a "query plan" that...

...Most of the time, we don’t need to worry about this plan because SQL engines are highly optimized and can generate efficient execution strategies automatically. However, if a query...

Search in all decks