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 Redirect2Link
class Webpage < ApplicationRecord
def self.delete_all
raise ActiveRecord::DeleteRestrictionError
end
def delete
destroy
end
An 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-rails
is 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: true
to the necessary assets. I'm just copying the default Rails7.0.0
config. This differs from the original Rails7.0.0.alpha2
install.
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