class NotificationsChannel < ApplicationCable::Channel
def subscribed
stream_for current_user
end
def unsubscribed
module Middleware
class RequestTimer
def initialize(app)
@app = app
end
module Types
class PostType < Types::BaseObject
field :id, ID, null: false
field :title, String, null: false
field :body, String, null: false
field :excerpt, String, null: true
production:
primary:
adapter: postgresql
url: <%= ENV['DATABASE_URL'] %>
pool: <%= ENV.fetch("RAILS_MAX_THREADS", 5) %>
primary_replica:
class PaymentService
def initialize
Stripe.api_key = Rails.application.credentials.stripe[:secret_key]
end
def create_payment_intent(amount:, currency: 'usd')
class AddDeletedAtToPosts < ActiveRecord::Migration[6.1]
def change
add_column :posts, :deleted_at, :datetime
add_index :posts, :deleted_at
end
end
require 'swagger_helper'
RSpec.describe 'Api::V1::Posts', type: :request do
path '/api/v1/posts' do
get 'Retrieves all posts' do
tags 'Posts'
class TrendingPostsService
CACHE_KEY = 'trending_posts:v1'.freeze
CACHE_TTL = 15.minutes
def self.call(limit: 10)
Rails.cache.fetch(CACHE_KEY, expires_in: CACHE_TTL) do
class AddConstraintsToUsers < ActiveRecord::Migration[6.1]
def change
# Null constraints
change_column_null :users, :email, false
change_column_null :users, :username, false
class CreateComments < ActiveRecord::Migration[6.1]
def change
create_table :comments do |t|
t.references :commentable, polymorphic: true, null: false
t.references :author, null: false, foreign_key: { to_table: :users }
t.text :body, null: false
class ProcessPaymentWorker
include Sidekiq::Worker
sidekiq_options queue: :critical, retry: 10
sidekiq_retry_in do |count, exception|
module Webhooks
class StripeController < ApplicationController
skip_before_action :verify_authenticity_token
def create
payload = request.body.read