Skip to content

xray-rails 0.3.2 and sprockets 4 #113

@rocket-turtle

Description

@rocket-turtle

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions