class UsersController
def index
@users = User.all
respond_to do |format|
format.html
format.json { render json: @users.as_json }
end
end require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Redirect2Linkclass Webpage < ApplicationRecord
def self.delete_all
raise ActiveRecord::DeleteRestrictionError
end
def delete
destroy
endAn API for adding new finders, creators, and other factory-type methods that are only used as part of this association.
class AnonymousSession < ApplicationRecord
has_many :webpages, as: :owner do
def nullify_owners
# records returns an array of webpages
records.each(&:nullify_owner)- Make sure
sprockets-railsis installed. This wasn't the case when using Rails7.0.0.alpha2. I think this was the most important step.
# Gemfile
gem "sprockets-rails"- Add
preload: trueto the necessary assets. I'm just copying the default Rails7.0.0config. This differs from the original Rails7.0.0.alpha2install.
class Webpage < ApplicationRecord
has_one_attached :open_graph_image
validate :open_graph_image_content_type
validate :open_graph_image_size
private
def open_graph_image_content_type