Rails 3.0.9中的ckeditor

时间:2012-12-14 10:32:41

标签: ruby-on-rails-3 ckeditor

我的项目使用Rails 3.0.9并且我添加了CKeditor 3.6.3,在开发工作正常,并且在Heroku中的Staging工作也很好,但在生产崩溃应用程序。

这是我必须制作的配置:

配置/ application.rb中

    config.autoload_paths += %W(#{config.root}/app/models/ckeditor)


配置/环境/ production.rb

    #config.assets.precompile += Ckeditor.assets

我对该行进行了评论,因为在Rails 3.1之前,config.assets不可用,但我现在不想升级Rails。


应用程序/模型/ CKEditor的/ attachment_file.rb

    class Ckeditor::AttachmentFile < Ckeditor::Asset
      has_attached_file :data,
                        :storage => :s3,
                        :s3_credentials => "#{Rails.root}/config/s3.yml",
                        :path => ":attachment/:id/:style.:extension",
                        :url => ":s3_domain_url"

      validates_attachment_size :data, :less_than => 100.megabytes
      validates_attachment_presence :data

      def url_thumb
        @url_thumb ||= Ckeditor::Utils.filethumb(filename)
      end
    end


应用程序/模型/ CKEditor的/ picture.rb

    class Ckeditor::Picture < Ckeditor::Asset
      has_attached_file :data, :styles => { :content => '800>', :thumb => '118x100#' },
                               :storage => :s3,
                               :s3_credentials => "#{Rails.root}/config/s3.yml",
                               :path => ":picture/:id/:style.:extension",
                               :url => ":s3_domain_url"

     validates_attachment_size :data, :less_than => 2.megabytes
     validates_attachment_presence :data

     def url_content
       url(:content)
     end
   end


我收到了下一个错误:

/home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing_from_s3_library': uninitialized constant Ckeditor::Asset (NameError)
from /home/jorge/trabajos/blanet/app/models/ckeditor/attachment_file.rb:1:in `<top (required)>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/engine.rb:137:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/engine.rb:137:in `block in eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/engine.rb:135:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/engine.rb:135:in `eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/application.rb:108:in `eager_load!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
from /home/jorge/trabajos/blanet/config/environment.rb:5:in `<top (required)>'
from /home/jorge/trabajos/blanet/config.ru:3:in `block in <main>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /home/jorge/trabajos/blanet/config.ru:1:in `new'
from /home/jorge/trabajos/blanet/config.ru:1:in `<main>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /home/jorge/.rvm/gems/ruby-1.9.2-p290@rails3/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'


任何人都可以帮助我?

感谢您提前。

1 个答案:

答案 0 :(得分:0)

看起来它无法加载附件的父类。 Ckeditor::Asset在某处定义了吗?它被加载了吗?也许你需要一个require ckeditor/asset