Code Explainers

Code explainers tagged #strong-parameters

ruby
class Api::MessagesController < ApiController
  before_action :authenticate_api_key!
 
  rate_limit to: 100,

Layered API rate limiting in Rails

rate-limiting api-authentication throttling
Intermediate 9 steps
ruby
class ProjectsController < ApplicationController
  before_action :set_project, only: %i[show update destroy]
 
  def create

Scoping a Rails API controller to Current.account

multitenancy strong-parameters nested-attributes
Intermediate 7 steps
ruby
class OrdersController < ApplicationController
  rescue_from ActiveRecord::RecordNotUnique, with: :handle_duplicate_submission
 
  def create

Idempotent order creation in Rails

idempotency database-constraints error-handling
Intermediate 8 steps
ruby
module Api
  module V2
    class ArticlesController < Api::BaseController
      before_action :set_article, only: %i[show update destroy]

Building a versioned JSON API controller in Rails

rest-api serialization pagination
Intermediate 10 steps
ruby
class ArticlesController < ApplicationController
  before_action :set_article, only: %i[show edit update destroy publish]
 
  def edit

Policy-based authorization in a Rails controller

authorization policy-object before-action
Intermediate 9 steps
ruby
class OrderConfirmationJob < ApplicationJob
  queue_as :mailers
 
  retry_on Net::OpenTimeout, wait: :polynomially_longer, attempts: 5

Resilient background jobs in Rails

background-jobs retries idempotency
Intermediate 8 steps
ruby
class ArticlesController < ApplicationController
  before_action :authenticate_user!
  before_action :set_article, only: %i[show edit update destroy]
  before_action :authorize_owner!, only: %i[edit update destroy]

How before_action filters guard a Rails controller

filters authorization callbacks
Intermediate 9 steps