Skip to content

Commit 85e85b7

Browse files
committed
Fix bug in Admin::ProjectsController
This avoids the following error when visiting /admin/projects in development: undefined method `host=' for #<ActiveStorage::Current:0x00007fdbbf782d80 @attributes={}> This method was deprecated in Rails 7.0[1] and removed in Rails 7.1[2]. We might also be able to use `ActiveStorage::SetCurrent`[3] here but I've gone for the smallest change that appears to work in development. [1]: https://github.com/rails/rails/blob/7-0-stable/activestorage/CHANGELOG.md [2]: https://github.com/rails/rails/blob/7-1-stable/activestorage/CHANGELOG.md [3]: https://api.rubyonrails.org/classes/ActiveStorage/SetCurrent.html
1 parent eeed4e4 commit 85e85b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/controllers/admin/projects_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ def destroy_image
1717
private
1818

1919
def set_host_for_local_storage
20-
ActiveStorage::Current.host = request.base_url if Rails.application.config.active_storage.service == :local
20+
return unless Rails.application.config.active_storage.service == :local
21+
22+
ActiveStorage::Current.url_options = { host: request.base_url }
2123
end
2224
end
2325
end

0 commit comments

Comments
 (0)