jakobk
jakobk

Reputation: 1132

Rails / Heroku / Assets not being included

I have an application that uses redactor (a wysiwyg editor) it works perfectly locally, and it also works when I upload it, except the config file, which is located in a subfolder doesent do anything, when pushing to Heroku. I tried precompiling, using:

RAILS_ENV=production bundle exec rake assets:precompile

and

bundle exec rake assets:precompile

I have config.assets.enabled = false

The config.js file, that is not working on Heroku, is included in application.js as redactor-rails/config

What can be the problem ?

Upvotes: 2

Views: 815

Answers (1)

Jamie Folsom
Jamie Folsom

Reputation: 1297

Have you added config.js to your local git repository before pushing?

[Edit]

A couple more things to check. Are you using the redactor-rails gem, and if so, is it in your gemfile?

gem 'jquery-rails'
gem 'redactor-rails'

Is your gemfile.lock checked into git?

[Edit 2]

I've now tested this out, and indeed, there's an issue with redactor-rails, which causes custom config to be overwritten by the gem's default.

On the github repo, there is a solution, which I've tested on heroku, and copied here:

rails generate redactor:config generates the file app\assets\redactor-rails\config.js. This will not work in the asset pipeline correctly as the rake assets:precompile task will still take config.js from the gem instead of the app (not that it'll work fine in development though). See Overriding backend assets in production environment

The solution is to create your own config.js (or any file name) and put it anywhere in your >app's assets. Then when requiring redactor, instead of //= require redactor-rails, use:

//= require redactor-rails/redactor.min
//= require path/to/custom/config

Works for me. Hope that helps. https://github.com/SammyLin/redactor-rails/issues/16

Upvotes: 6

Related Questions