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

xray-rails 0.3.2 and sprockets 4 #113

Open
rocket-turtle opened this issue Oct 15, 2021 · 0 comments
Open

xray-rails 0.3.2 and sprockets 4 #113

rocket-turtle opened this issue Oct 15, 2021 · 0 comments

Comments

@rocket-turtle
Copy link

We had some trouble to upgrade to sprockets 4 so I want to share our solution.

Include this MP in your application.rb (xray-rails must allready be required)

      config.after_initialize do
        if Gem::Version.new(Xray::VERSION) > Gem::Version.new('0.3.2')
          raise('This monkey patch is no longer necessary.')
        end

        Xray::Engine::JavascriptPreprocessor.class_eval do
          # See also https://github.com/brentd/xray-rails/issues/88
          # This is fixed in https://github.com/brentd/xray-rails/pull/103
          def self.run(filename, source, context)
            path = Pathname.new(context.filename).to_s
            if path =~ /^#{Rails.root}.+\.(jst)(\.|$)/
              Xray.augment_template(source, path)
            else
              source
            end
          end
        end
      end

This will no longer be necessary with the next release of xray-rails.
You could include

Add = javascript_include_tag 'xray', nonce: true if Rails.env.development? as last element of the head tag.
You need to make sure jQuery is already available.

Add = render partial: '/xray_bar' if Rails.env.development? as first element of the body tag.
This will no longer be necessary if this MR is merged #101

Please let me know if you made some different changes.

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