#StackBounty: #ruby-on-rails #cors #ruby-on-rails-5 Rails Font CORS policy

Bounty: 50

I can’t load this font for a CORS Policy.

Folder: app/assets/fonts/Inter-UI.var.woff2

<%=preload_link_tag("Inter-UI.var.woff2", as:'font', crossorigin: "anonymous")%>

Error:

Access to font at
http://localhost:3000/assets/Inter-UI.var-e2e323d19d24946c4d481135af27ba00f3266aa9d4abe4262e97088feccb6ca4.woff2
from origin ‘http://0.0.0.0:3000‘ has been blocked by CORS policy: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource.

Response HTTP status code

enter image description here

If I go directly to http://localhost:3000/assets/Inter-UI.var-e2e323d19d24946c4d481135af27ba00f3266aa9d4abe4262e97088feccb6ca4.woff2 I can download the file successfully.

I have already tried with rack-cors gem, but it’s not working

config/environments/developement.rb

Rails.application.configure do

  config.middleware.insert_before 0, Rack::Cors do
    allow do
      origins '*'
      resource '*', :headers => :any, :methods => :any
    end
  end


Get this bounty!!!

#StackBounty: #ruby-on-rails-5 #activeadmin Customizing the Comments' Index and Show Pages in ActiveAdmin

Bounty: 50

I want to be able to edit the Comments’ Index and Show Pages in ActiveAdmin. By default the Index Page shows 6 attributes: resource_type, author_type, resource, author, body and created_at. But I want to show only resource, author, body and created_at. Also I want to be able to edit the filter and the Show Page and choose which columns to show and which ones not.

What can I do?


Get this bounty!!!

#StackBounty: #ruby-on-rails #ruby #ruby-on-rails-5 #monkeypatching #rails-activestorage Monkey patching ActiveStorage::Attachment gets…

Bounty: 50

So I decided to add an url attr_accessor to ActiveStorage::Attachment objects.

In development the patch holds for a while until it seems to “have been lost”. Meaning it works for few minutes, then it does not work anymore. Then I need to restart the server in order to get the patch applied again. I believe I am not patching correctly and I would need advises in that mater.


Here is what I tried:

lib/ext/active_storage/attachment.rb

First try :

module ActiveStorageUrl
  extend ActiveSupport::Concern

  included do
    attr_accessor :url
  end
end

ActiveStorage::Attachment.send :include, ActiveStorageUrl

Second try

class ActiveStorage::Attachment < ActiveRecord::Base
  attr_accessor :url
end

And by the way in both case it’s loaded with this:

config/initializers/monkey_patches.rb

require 'ext/active_storage/attachment'

So when it work I have no error message, but after a while the patch “diseapear” (lacking better terms), and I get the following error, telling me my attr_accessor is not there anymore. Rails must have reloaded ActiveStorage classes and my patch is lost.

Module::DelegationError in Products#images
url delegated to blob, but blob is nil


Get this bounty!!!