# In rails console
query = Post.joins(:author)
.where(published_at: 1.week.ago..Time.current)
.where(users: { status: 'active' })
.order(created_at: :desc)
class PostsController < ApplicationController
def create
@post = current_user.posts.build(post_params)
if @post.save
flash[:success] = 'Post was successfully created.'
AuditLog.create!(
actor_id: current_user.id,
action: 'member.approve',
target_type: 'Member',
target_id: member.id,
ip_address: request.remote_ip,
<nav class="flex gap-2">
<%= link_to 'Profile', settings_path(tab: 'profile'), data: { turbo_frame: 'tab_content' } %>
<%= link_to 'Billing', settings_path(tab: 'billing'), data: { turbo_frame: 'tab_content' } %>
</nav>
<%= turbo_frame_tag 'tab_content' do %>
class Message < ApplicationRecord
belongs_to :room
broadcasts_to ->(message) { [message.room, :messages] }, inserts_by: :prepend
end
Rails.application.routes.draw do
namespace :api do
namespace :v1 do
resources :users, only: [:index, :show, :create, :update]
resources :posts do
resources :comments, only: [:index, :create]
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["field"]
connect() {
respond_to do |format|
format.turbo_stream
format.html { redirect_to projects_path, notice: 'Created.' }
end
class WizardsController < ApplicationController
before_action :load_draft
def step_1
render_step(1)
end
module Middleware
class RequestTimer
def initialize(app)
@app = app
end
class Maintenance::BackfillSnipScoresJob < ApplicationJob
queue_as :maintenance
def perform
ActiveRecord::Base.connection_pool.with_connection do |conn|
conn.verify!
<article class="post">
<h1><%= @post.title %></h1>
<%= simple_format @post.body %>
<!-- Lazy load comments when scrolled into view -->
<%= turbo_frame_tag "post_#{@post.id}_comments",