5

I am working on a project that needs to alter Refinery's WYMEditor behavior a bit. This is easily done by overriding jquery.refinery.wymeditor.js using rake refinery:override and editing it to my own needs, which works fine in development environment.

However, when it comes to production, overrides are ignored. That is, the compiled asset just contains jquery.refinery.wymeditor.js from bundle, and editing that file directly there may give the desired effect, but that's just not the way it should be done.

Strange thing is, that the problem apparently manifests itself only when trying to override backend-related assets.

It might be useful to know that I am using refinery-edge.

Any help appreciated.

unclenorton
  • 1,605
  • 11
  • 19
  • did you manage to fix this? I am having the same issue. – bluediapente Oct 27 '11 at 19:51
  • Not yet, unfortunately. I will update this if any details appear. – unclenorton Oct 27 '11 at 22:42
  • I might have come to a solution. In short, the problem is that if the overridden file is included via sprockets' `require`, then the file that contains this inclusion, as well as all other files it includes, has to be overridden too. Take a look at `/app/assets/javascripts/refinery/refinery.js` in bundle. I will post the detailed answe later today. – unclenorton Oct 31 '11 at 10:59
  • Well, I think I'm done with this. @Lilitu88, what's your progress? – unclenorton Nov 04 '11 at 16:49
  • I figured out the same thing. Ended up with an ugly hack, not a real fix. – bluediapente Nov 06 '11 at 19:57

2 Answers2

3

So I have managed to beat it. First thing to mention is that it wouldn't be possible without poking into Refinery source code.

As I have already written in the comment, the problem was that I was trying to override an asset (wymeditor/jquery.refinery.wymeditor.js in my case) that wasn't included in a view directly, but was referenced in another asset, which was taken from the gem. And since sprockets knows nothing about Refinery's overrides, it took the referenced assets by the relative path, i.e. from the gem (and hence, unmodified), too. So, again, in my case the solution was to override the refinery/wymeditor.js, and everything worked as a charm.

Should you need to change any other backend script than WYMEditor, you will most likely have to override the refinery/refinery.js, which includes all other backend scripts, in addition to the very script you need to modify.

There is one big concern, though. With all these overrides, I have made any updates very error-prone, since some files will update, and some will not. It could have been avoided by overriding everything, but that effectively means no updates at all.

unclenorton
  • 1,605
  • 11
  • 19
0

Try changing the name of the generated file and including that in your manifest instead of the original name. I suspect that it is preferring the original in the presence of two assets named the same thing.

Richard Hulse
  • 10,383
  • 2
  • 33
  • 37
  • we are trying to override the other file. If I am not mistaken, with this method you have them both. Right? – bluediapente Oct 27 '11 at 19:52
  • Yes, if you rename the generated file you should have both available in production. Does the generated file contain all the javascript? If it does then remove the name of the original file from the manifest, rename the generated file, include that in your manifest, and you should be good to go. BTW, are you precompiling your assets? – Richard Hulse Oct 28 '11 at 08:26
  • I have tried both precompiling and compiling on-the-go with the same result. Will try your solution today and see what comes out of it. – unclenorton Oct 28 '11 at 12:51