Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with ActiveStorage in Rails 6 #70

Open
TheBrockEllis opened this issue Jun 4, 2022 · 0 comments
Open

Issues with ActiveStorage in Rails 6 #70

TheBrockEllis opened this issue Jun 4, 2022 · 0 comments

Comments

@TheBrockEllis
Copy link

TheBrockEllis commented Jun 4, 2022

Hi all!

This gem looks spiffy and I was really excited to try it. I plugged it into the site that I was working on and found that it broke a bunch of links to user-uploaded content. I use ActiveStorage with S3 and images were showing up as broken links.

After poking around, I figured out that Active Storage was generating some redirect URLS under the hood to display the blobs and Lockup was hijacking those redirects with the Code page.

I ended up copying the ActiveStorage controller and modifying it slightly to include the skip_before_action that was not being inherited from the ApplicationController.

app/controllers/active_storage/blobs/redirect_controller.rb

class ActiveStorage::Blobs::RedirectController < ActiveStorage::BaseController
  skip_before_action :check_for_lockup, raise: false
  include ActiveStorage::SetBlob

  def show
    expires_in ActiveStorage.service_urls_expire_in
    redirect_to @blob.url(disposition: params[:disposition]), allow_other_host: true
  end
end

You can see the original source of the ActiveStorage controller here.

Not sure there's anything to do here, but I felt like I may as well document my findings and maybe save someone a few hours. Feel free to close this issue if there's no action items. Thanks!

Edit: Actually, this didn't fix things much either. Making the changes above fixed uploading images but broke the displaying of images hosted through ActiveRecord's S3 integration. I guess extending the ActiveStorage controllers is not quite as easy as other controllers are. This gentleman has a proposal where he mentions that you either have to copy the routes from ActiveStorage into your routes.rb file, or use custom route helpers and lose the fancy helpers that ActiveStorage provides. I tried a few different combinations of that and couldn't get things to work. Going to have to put Lockup on the shelf until I can spend more time trying to get things working together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant