class PasswordResetsController < ApplicationController
before_action :find_user_by_token, only: [:edit, :update]
def create
user = User.find_by(email: params[:email]&.downcase)
<nav id="main-navbar"
data-turbo-permanent
data-controller="navbar"
data-navbar-menu-open-value="false"
class="navbar">
<div class="navbar-inner">
# app/policies/post_policy.rb
class PostPolicy < ApplicationPolicy
class Scope < Scope
def resolve
if user.admin?
scope.all
<%= turbo_stream_from :comments %>
<section class="comments">
<h2>Discussion</h2>
<%= turbo_frame_tag "new_comment" do %>
class UserSearchQuery
def initialize(relation = User.all)
@relation = relation
end
def call(params)
class Post < ApplicationRecord
has_many :comments, dependent: :destroy
# comments_count is maintained by counter_cache on Comment#belongs_to
scope :stale_comment_counts, lambda {
class CommentsController < ApplicationController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.build(comment_params)
@comment.author = current_user
class TransferFundsService
def initialize(from_account:, to_account:, amount:)
@from_account = from_account
@to_account = to_account
@amount = amount
end
<div class="layout" data-controller="sidebar">
<aside class="sidebar">
<%= render "shared/sidebar", active: params[:controller] %>
</aside>
<main class="content-area">
class AddSoftDeleteToDocuments < ActiveRecord::Migration[7.0]
def change
add_column :documents, :deleted_at, :datetime
add_index :documents, :deleted_at
# Replace the global unique index with one scoped to live rows,
<div class="orders-layout" data-controller="drawer">
<table class="orders">
<tbody>
<% @orders.each do |order| %>
<tr>
<td><%= order.reference %></td>
class User < ApplicationRecord
has_many :posts
has_many :comments
scope :digest_subscribers, -> {
where(digest_opt_in: true).where.not(confirmed_at: nil)