class WikiAsset < ApplicationRecord self.primary_key = :wiki_page_id, :no belongs_to :wiki_page belongs_to :created_by_user, class_name: 'User' has_one_attached :file validates :file, presence: true def url Rails.application.routes.url_helpers.rails_blob_url(file, only_path: true) end end