rich icon indicating copy to clipboard operation
rich copied to clipboard

Rails 4 and asset paths in development mode

Open pehlert opened this issue 11 years ago • 16 comments

I was trying to use rich with a brand new Rails 4 app and ActiveAdmin today. However, while I managed to load rich properly, I realised that the asset_path helper in e.g. ckeditor.js.erb returns only "/ckeditor" instead of the expected "/assets/ckeditor".

This causes CKEditor to not load properly.

I tried various tweaks to my asset pipeline configuration, but non of them helped. When I added the "/assets/" prefix manually, CKEditor came up as expected.

Can someone confirm this behavior before I investigate further?

pehlert avatar Jun 25 '13 18:06 pehlert

To be honest I haven't tested Rich on Rails 4 yet. Do you think there is a way to make this work with Rails 4 without breaking Rails 3 compatibility?

bastiaanterhorst avatar Jun 26 '13 12:06 bastiaanterhorst

Hey Bastiaan,

Quite frankly, I have no deeper knowledge of what was changed or not to the asset pipeline and how things are expected to work. I downgraded my application to 3.2 yesterday because it was too much of a hassle with all the library incompatibilities.

I might be able to look into it if someone confirms that the issue happens for him as well to rule out my environment as the cause. So I'd appreciate if you could leave this around a bit longer until someone else comments.

pehlert avatar Jun 26 '13 15:06 pehlert

It happens for me as well on new Rails 4 app with Active Admin on the rails4 branch.

Started GET "/ckeditor/config.js?t=D08E" for 127.0.0.1 at 2013-07-01 17:30:26 -0400

ActionController::RoutingError (No route matches [GET] "/ckeditor/config.js"):
  actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
  railties (4.0.0) lib/rails/engine.rb:511:in `call'
  railties (4.0.0) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /Users/mwlang/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  /Users/mwlang/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  /Users/mwlang/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

mwlang avatar Jul 01 '13 21:07 mwlang

I'll try to look into this soon. In the mean time, I'd love to hear it if anyone finds a solution. Preferably one that is backwards compatible.

bastiaanterhorst avatar Jul 02 '13 20:07 bastiaanterhorst

Sorry guys, been busy with other things lately. I really hope that I will get a chance to look into it this week. Otherwise I'd also love to hear why it breaks from someone else. Thanks!

pehlert avatar Jul 03 '13 03:07 pehlert

I got the same problem with Rails 4, Rails Admin and Rich, it looks for "MediaEmbed" and "richfile" inside "/ckeditor" instead "/assets/ckeditor".

glaucocustodio avatar Jul 10 '13 16:07 glaucocustodio

Follow the workaround I have done to get rich, rails admin and rails 4 working https://gist.github.com/glaucocustodio/5985229

glaucocustodio avatar Jul 12 '13 15:07 glaucocustodio

Other thing to keep in mind when rolling into Production, in the models attr_acessible has been removed in Rails 4.

kim3er avatar Jul 17 '13 14:07 kim3er

Fix for Active Admin

i just applied your edits to the following files /assets/javascripts/rich/editor/ckeditor_path.js /assets/javascripts/rich/editor/rich_editor.js.erb

moehassan avatar Aug 02 '13 22:08 moehassan

There's now an experimental rails4 branch where @dunyakirkali is working his magic.

bastiaanterhorst avatar Aug 06 '13 13:08 bastiaanterhorst

I couldn't find any rails4 branch, any progress on it?

kirs avatar Dec 30 '13 11:12 kirs

I just had the same problem (with Rails 4 and ActiveAdmin). It turns out it is already fixed in master branch, but the gem you get by default is an old one. The Gemfile entry should look like this:

gem 'rich', github: 'bastiaanterhorst/rich'

... and then it works fine.

rrrodrigo avatar Jan 15 '14 13:01 rrrodrigo

@bastiaanterhorst could you release it on Rubygems, please?

kirs avatar Jan 15 '14 16:01 kirs

@kirs I'd like to do some more thorough testing before releasing a new gem, but am a bit tied up at the moment. So for now: use the master branch.

bastiaanterhorst avatar Jan 16 '14 11:01 bastiaanterhorst

Tell me if I can help you with the gem somehow.

On 16 January 2014 12:29, Bastiaan Terhorst [email protected]:

@kirs https://github.com/kirs I'd like to do some more thorough testing before releasing a new gem, but am a bit tied up at the moment. So for now: use the master branch.

— Reply to this email directly or view it on GitHubhttps://github.com/bastiaanterhorst/rich/issues/88#issuecomment-32461221 .

kirs avatar Jan 16 '14 13:01 kirs

@bastiaanterhorst Maybe it should be mentioned in the README, that the current rich release is not yet working perfectly with Rails 4 and the user should use the master branch instead?

KrauseFx avatar Mar 09 '14 11:03 KrauseFx