SammyLin / redactor-rails

This repo is deprecated. Please check out official gem for Redactor 2. https://github.com/Redactor2/redactor2_rails
MIT License
389 stars 253 forks source link

Asset pipeline ignores custom config.js. Only the gem's config.js is being loaded #87

Closed hoenth closed 11 years ago

hoenth commented 11 years ago

I have installed and configured redactor-rails, and in development, it works perfectly, including several plugins, and changing the buttons.

However, when i push to our beta servers, using precompiled assets delivered via the asset pipeline, only the config.js from the gem appears.

Reading up on this a bit, there is a discussion of how to overwrite specific gem asset files here: http://stackoverflow.com/questions/16435428/rails-how-to-override-single-files-from-gem-assets-for-assetsprecompile-solv

I didn't see any wizardry within the redactor-rails gem that would lead me to believe that the above is not necessary, but also assume that I am not the first person to deploy redactor-rails with a custom config.js file either.

Have others not had this issue? Is there a work around I am missing?

Tom

hoenth commented 11 years ago

By changing the index.js file from:

//= require ./redactor.min
//= require ./config

to:

//= require redactor-rails/redactor.min
//= require redactor-rails/config

fixed the issue

betjaminrichards commented 10 years ago

Just a note for people trying to test redactor-rails with capybara: This issue also affects your test environment, so any changes made to config.js will not be carried over into this unless you change the line as above.

As a FYI you can easily integrate redactor testing into your test suite by adding the following code to your spec_helper.rb file:

def fill_in_redactor(options)
  if options[:in]
    node = "('#{options[:in]}')"
  else
    node = "('.redactor')"
  end
  page.execute_script( "$#{node}.redactor('set', '#{options[:with]}')" )
end

And the calling the function from in your test with the content you want to paste in:

fill_in_redactor :in => "#new_post_text_area", :with => newpost.body

StarWar commented 8 years ago

For me it says "Cannot read property 'set' of undefined"