{"action":"created","issue":{"url":"https://api.github.com/repos/refinery/refinerycms/issues/3383","repository_url":"https://api.github.com/repos/refinery/refinerycms","labels_url":"https://api.github.com/repos/refinery/refinerycms/issues/3383/labels{/name}","comments_url":"https://api.github.com/repos/refinery/refinerycms/issues/3383/comments","events_url":"https://api.github.com/repos/refinery/refinerycms/issues/3383/events","html_url":"https://github.com/refinery/refinerycms/issues/3383","id":343227288,"node_id":"MDU6SXNzdWUzNDMyMjcyODg=","number":3383,"title":"Interference between Marketable Pages & ActiveStorage (Rails 5.2)","user":{"login":"Obi-TOB","id":7891183,"node_id":"MDQ6VXNlcjc4OTExODM=","avatar_url":"https://avatars0.githubusercontent.com/u/7891183?v=4","gravatar_id":"","url":"https://api.github.com/users/Obi-TOB","html_url":"https://github.com/Obi-TOB","followers_url":"https://api.github.com/users/Obi-TOB/followers","following_url":"https://api.github.com/users/Obi-TOB/following{/other_user}","gists_url":"https://api.github.com/users/Obi-TOB/gists{/gist_id}","starred_url":"https://api.github.com/users/Obi-TOB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Obi-TOB/subscriptions","organizations_url":"https://api.github.com/users/Obi-TOB/orgs","repos_url":"https://api.github.com/users/Obi-TOB/repos","events_url":"https://api.github.com/users/Obi-TOB/events{/privacy}","received_events_url":"https://api.github.com/users/Obi-TOB/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-07-20T19:48:09Z","updated_at":"2018-07-24T03:39:12Z","closed_at":null,"author_association":"NONE","body":"RefineryCMS (with Rails 5.2. support) in combination with SpreeCommerce 3.6.2:\r\n\r\nWhen mounting Refinery in root\r\n```\r\nRails.application.routes.draw do\r\n  mount Spree::Core::Engine, at: '/shop'\r\n  mount Refinery::Core::Engine, at: '/'\r\nend\r\n```\r\n\r\nmarketable_page routes interfere with ActiveStorage, i.e. the Refinery route matches and  Refinery::PagesController takes over request:\r\n```\r\nStarted GET \"/rails/active_storage/disk/eyJf [...] g.jpeg\" for 127.0.0.1 at 2018-07-20 21:31:58 +0200\r\nProcessing by Refinery::PagesController#show as JPEG\r\n  Parameters: {\"content_type\"=>\"image/jpeg\", \"disposition\"=>\"inline; filename=\\\"ror_bag.jpeg\\\"; filename*=UTF-8''ror_bag.jpeg\", \"path\"=>\"rails/active_storage/disk/eyJ [..] g\", \"locale\"=>\"en\"}\r\n```\r\nI'm not really sure why this happens as the ActiveStorage routes are above the Refinery routes:\r\n```\r\nrake routes | grep 'pages#show\\|rails'\r\n[...]\r\nrails_disk_service GET  /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show\r\n[...]\r\nmarketable_page GET    /*path(.:format)                           refinery/pages#show\r\n[...]\r\n```\r\nRemoving the mount point for Refinery or moving it to a different path however resolves the issue.\r\n\r\nI resolve this now by a hacky route constraint in Refinery, however I would be interested why this happpens and how to resolve it 'right'.\r\n```\r\ndef append_marketable_routes\r\n  Refinery::Core::Engine.routes.append do\r\n    get '*path', :to => 'pages#show', constraints: lambda { |req| !req.env[\"REQUEST_URI\"].starts_with? \"/rails/active_storage/\" }, :as => :marketable_page\r\n  end\r\nend\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/refinery/refinerycms/issues/comments/407270695","html_url":"https://github.com/refinery/refinerycms/issues/3383#issuecomment-407270695","issue_url":"https://api.github.com/repos/refinery/refinerycms/issues/3383","id":407270695,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNzI3MDY5NQ==","user":{"login":"parndt","id":10128,"node_id":"MDQ6VXNlcjEwMTI4","avatar_url":"https://avatars3.githubusercontent.com/u/10128?v=4","gravatar_id":"","url":"https://api.github.com/users/parndt","html_url":"https://github.com/parndt","followers_url":"https://api.github.com/users/parndt/followers","following_url":"https://api.github.com/users/parndt/following{/other_user}","gists_url":"https://api.github.com/users/parndt/gists{/gist_id}","starred_url":"https://api.github.com/users/parndt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parndt/subscriptions","organizations_url":"https://api.github.com/users/parndt/orgs","repos_url":"https://api.github.com/users/parndt/repos","events_url":"https://api.github.com/users/parndt/events{/privacy}","received_events_url":"https://api.github.com/users/parndt/received_events","type":"User","site_admin":false},"created_at":"2018-07-24T03:39:12Z","updated_at":"2018-07-24T03:39:12Z","author_association":"MEMBER","body":"What might also work is mounting Spree _after_ Refinery as, from memory, in a routes file the routes that are declared last override routes declared before that point. However, that won't fix our underlying issue.\r\n\r\nWhat we could also do is expose a configuration value in pages config like:\r\n\r\n```\r\nconfig.reserved_paths = %w(/active_storage)\r\n```\r\n\r\nThen we can use it like this:\r\n\r\n```ruby\r\nconstraints: -> { |request| Refinery::Pages.config.reserved_paths.any? { |path| !request.env['REQUEST_URI'].start_with?(path) } }\r\n```"}}
{"actor":{"display_login":"parndt"}}