Eduardo Almeida
Eduardo Almeida

Reputation: 410

Correct use of non-stupid-digest-assets gem

Even though it is a very, very simple gem, I believe I don't understand the idea behind non-stupid-digest-assets (https://github.com/alexspeller/non-stupid-digest-assets) since it isn`t working on my app.

I need to use CKEDITOR on my app, but the rails digest is messing everything up.

I added this to config/initializers/non_digest_assets.rb:

NonStupidDigestAssets.whitelist = [/ckeditor\/.*/]

But my ckeditor files still don't show up.

Could someone help me?

Upvotes: 0

Views: 1869

Answers (2)

scoots
scoots

Reputation: 715

We just ran into a similar issue, and it was because we needed to force the assets to be recompiled.

Mina normally handles this for us but in this case it skipped precompiling the assets because it didn't detect any changes.

Upvotes: 1

whoughton
whoughton

Reputation: 1385

As a starting point of information the test is against the FULL path to the file from WITHIN each asset directory.

Initially I thought perhaps his RegEx was in error, but it actually seems to be fine. The question may really be does the RegEx given match your needs. To break it down, here's the regex you gave:

/ckeditor\/.*/

Given the following provided file paths:

  1. ckeditor/blah.js
  2. ckeditor_blah.js
  3. ckEditor.main.js
  4. ckEditor/main.js
  5. in/ckeditor.css
  6. in/ckeditor/extra.css
  7. in/blockeditor/base.css
  8. ckeditor5/temp.js

This will match only lines 1, 6 and 7, this is because it is looking for paths that contain the text "ckeditor/" in them. The ".*" in the Regex is actually superfluous (I believe) since it is only adding that the string can contain 0 to infinite characters after "ckeditor/".

The other thing to note is that this is CASE SENSITIVE, so if your file path is actually ckEditor/main.js as in the 4th line of the example above it will not match. If you need the RegEx to be case-insensitive, use:

/ckeditor\/.*/i

Hopefully this helps you dig through the problem... Here's some supplemental examples to provide more starting points:

/^ckeditor/i

This will match lines 1, 2, 3, 4 and 8 in the example above, as it will search for any path starting with "ckeditor" and is case-INsensitive.

/[\/]*ckeditor[\/]/i

This will match lines 1, 4, 6 and 7 in the example above. It is search for any file path that may (but is not required) start with "/", and contains "ckeditor/"

/ckeditor.*[\/]/i

This will match lines 1, 4, 6, 7 and 8. It is essentially saying that any file path that contains "ckeditor{any number of any characters other than newline}/" will work.

Upvotes: 1

Related Questions