2014-01-05 3 views
3

Я использую этот CKEditor перл: https://github.com/galetahub/ckeditorRails CKEditor Gem дает 404

Я следовал инструкциям на README, но когда я пытаюсь поставить f.cktext_area я получаю некоторые ошибки 404:

GET http://localhost:5000/ckeditor/config.js?t=DAED 404 (Not Found) ckeditor.js?body=1:78 
GET http://localhost:5000/ckeditor/skins/moono/editor.css?t=DAED 404 (Not Found) ckeditor.js?body=1:78 
GET http://localhost:5000/ckeditor/lang/en.js?t=DAED 404 (Not Found) ckeditor.js?body=1:78 
Uncaught TypeError: Cannot set property 'dir' of undefined ckeditor.js?body=1:214 

I запустили rails generate ckeditor:install --orm=active_record --backend=paperclip и rake db:migrate

config.autoload_paths += %W(#{config.root}/app/models/ckeditor) в application.rb mount Ckeditor::Engine => '/ckeditor' в routes.rb и //= require ckeditor/init находится в моем JS ...

Я также перезапустил свой сервер разработки, но я все еще получаю эти 404.

В моей rake routes:

ckeditor  /ckeditor      Ckeditor::Engine 

Routes for Ckeditor::Engine: 
     pictures GET /pictures(.:format)    ckeditor/pictures#index 
       POST /pictures(.:format)    ckeditor/pictures#create 
     picture DELETE /pictures/:id(.:format)   ckeditor/pictures#destroy 
attachment_files GET /attachment_files(.:format)  ckeditor/attachment_files#index 
       POST /attachment_files(.:format)  ckeditor/attachment_files#create 

Я пропускаю что-то?

EDIT

Я хотел бы добавить, что localhost:5000/assets/ckeditor/config.js делает работу, как это делают остальные предваряется /assets/ ... почему не ckeditor.js использовать правильный путь активов?

ответ

2

Я не могу вспомнить, где я нашел решение (кто-то из вопросов, связанных с Github).

Это работает для меня:

Добавить это /lib/tasks/ckeditor.rake:

require 'fileutils' 

desc "Create nondigest versions of all ckeditor digest assets" 
task "assets:precompile" => :environment do 
    fingerprint = /\-([0-9a-f]{32})\./ 
    for file in Dir["public/assets/ckeditor/**/*"] 
    # Skip file unless it has a fingerprint 
    next unless file =~ fingerprint 

    # Get filename of this file without the digest 
    # (example) public/assets/ckeditor/config.js 
    nondigest = file.sub fingerprint, '.' 

    # Create a filename relative to public/assets 
    # (example) public/assets/ckeditor/config.js => ckeditor/config.js 
    filename = nondigest.sub 'public/assets/', '' 
    filename = filename.sub /.gz$/, ''   # Remove .gz for correct asset checking 

    # Fetch the latest digest for this file from assets 
    latest_digest = Rails.application.assets.find_asset(filename).try(:digest) 

    # Debug information 
    puts '---- ' + file + ' ----' 

    # Compare digest of this file to latest digest 
    # [1] is the enclosed capture in the fingerprint regex above 
    this_digest = file.match(fingerprint)[1] 
    if (this_digest == latest_digest) 
     # This file's digest matches latest digest, copy 
     puts 'Matching digest, copying ' + file 
     FileUtils.cp file, nondigest, verbose: true 
    else 
     # This file's digest doesn't match latest digest, ignore 
     puts 'Latest digest: ' + latest_digest 
     puts 'This digest: ' + this_digest 
     puts 'Non-matching digest, not copying ' + file 
    end 

    # Debug information 
    puts '---- end ----' 
    end 
end 
+0

Я добавил задача, я должен выполнить эту задачу отдельно? –

+0

@ error-404no вам не нужно. эта задача автоматически выполняется, когда вы нажимаете 'bundle exec rails assets: precompile' (или' bundle exec rake assets: precompile') – artificis