Yes you can. I assume that you have paperclip already set up for S3. So you have only edit the picture.rb and attachement_file.rb in you model directory (app/model/ckeditor/) and replace these lines
I would follow the README for the rails-ckeditor plugin you mentioned. If you don't need the SWFUpload, you can simply integrate the CKEditor and Paperclip, by writing a custom file uploader and custom file browser, and connect them to the editor by specifying urls and callback functions.
It is always useful to have an example, the author has made an example app. Unfortunately, there are a few errors in it. Consider the following points to make it running
change the following lines in config/environment.rb
:< a href="https://richonrails.com/articles/getting-started-with-ckeditor" rel="nofollow noreferrer">https://richonrails.com/articles/getting-started-with-ckeditor
As is, CKEditor allows you to embed existing image URLs, but for CKEditor and Paperclip to work together so you can upload images, you will need ImageMagick. As I understand, it handles uploading the image data, making an image URL reference for the uploaded image data and the embedding of the uploaded image data's URL.
CKEditor
Add gem "ckeditor" to your Gemfile
then run the $ bundle install command.
Add this to /app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require ckeditor/init <--------------- THIS
//= require_tree . <----------------------- ABOVE THIS
In addition to Zaparka's response, I had to remove #{Rails.root} as I was getting an unitialized constant error. SO instead I put "/config/s3.yml", and that worked.
发布评论
评论(5)
是的,你可以。我假设您已经为 S3 设置了回形针。因此,您只需编辑模型目录(app/model/ckeditor/)中的 picture.rb 和 Attachement_file.rb 并将这些行替换
为您的 papeclip 版本 has_attached_file:
就是这样。顺便说一句:这是 Rails 3 的示例。
Yes you can. I assume that you have paperclip already set up for S3. So you have only edit the picture.rb and attachement_file.rb in you model directory (app/model/ckeditor/) and replace these lines
with your papeclip version has_attached_file:
That's it. Btw: this is example from Rails 3.
我会遵循您提到的rails-ckeditor插件的README。如果您不需要 SWFUpload,则只需 通过编写自定义文件上传器和自定义文件浏览器来集成 CKEditor 和 Paperclip,并通过指定 url 和回调函数将它们连接到编辑器。
有一个例子总是有用的,作者制作了一个示例应用。不幸的是,其中有一些错误。请考虑以下几点以使其运行
更改
config/environment.rb 中的以下行
config.gem '回形针', :version =>; '2.3.3'
config.gem 'ckeditor', :version =>; '3.4.1'
删除公共文件
index.html
add config/routes.rb 的根路由
map.root:控制器=> "pages"
I would follow the README for the rails-ckeditor plugin you mentioned. If you don't need the SWFUpload, you can simply integrate the CKEditor and Paperclip, by writing a custom file uploader and custom file browser, and connect them to the editor by specifying urls and callback functions.
It is always useful to have an example, the author has made an example app. Unfortunately, there are a few errors in it. Consider the following points to make it running
change the following lines in
config/environment.rb
config.gem 'paperclip', :version => '2.3.3'
config.gem 'ckeditor', :version => '3.4.1'
delete the file
index.html
in publicadd a root route to config/routes.rb
map.root :controller => "pages"
Rails 4.2.0解决方案:
事实上,CKEditor 允许您嵌入现有的图像 URL,但为了让 CKEditor 和 Paperclip 一起工作以便您可以上传图像,您将需要 ImageMagick。据我了解,它处理上传图像数据、为上传的图像数据创建图像 URL 引用以及嵌入上传的图像数据的 URL。
CKEditor
将
gem "ckeditor"
添加到您的 Gemfile,然后运行
$ bundle install
命令。将其添加到 /app/assets/javascripts/application.js
中: https://github.com/galetahub/ckeditor#how-to-generate-models-to-store-uploaded-files
将其添加到:
/config/routes.rb
我把它放在使用它的
资源
之前使用“form_for" 并设置了一个带有 title:string 和 text:text 的“Article”模型
/app/views/articles/_form.html.erb
使用“simple_form_for”
回形针
:< a href="https://richonrails.com/articles/getting-started-with-ckeditor" rel="nofollow noreferrer">https://richonrails.com/articles/getting-started-with-ckeditor
将
gem“paperclip”
添加到您的Gemfile中并$bundle install
。然后运行以下两个命令:
$railsgenerateckeditor:install--orm=active_record--backend=paperclip
和
$rakedb:migrate
ImageMagick
对于macOS Sierra:
对于其他ImageMagick 安装选项:https://www.imagemagick.org/script/install-source。 php
Rails 4.2.0 solution:
As is, CKEditor allows you to embed existing image URLs, but for CKEditor and Paperclip to work together so you can upload images, you will need ImageMagick. As I understand, it handles uploading the image data, making an image URL reference for the uploaded image data and the embedding of the uploaded image data's URL.
CKEditor
Add
gem "ckeditor"
to your Gemfilethen run the
$ bundle install
command.Add this to /app/assets/javascripts/application.js
per: https://github.com/galetahub/ckeditor#how-to-generate-models-to-store-uploaded-files
Add this to:
/config/routes.rb
I put it before the
resources
which utilize itUsing "form_for" and having set up an "Article" model with a title:string and text:text
/app/views/articles/_form.html.erb
Using "simple_form_for"
Paperclip
per: https://richonrails.com/articles/getting-started-with-ckeditor
Add
gem "paperclip"
to your Gemfile and$ bundle install
.Then run the following two commands:
$ rails generate ckeditor:install --orm=active_record --backend=paperclip
and
$ rake db:migrate
ImageMagick
For macOS Sierra:
For other ImageMagick install options: https://www.imagemagick.org/script/install-source.php
使用以下对我有用的东西,但你应该在 Amazon 上拥有 s3 存储帐户和正确的端点,你可以参考下面的
`
注释此行
require "ckeditor/orm/active_record"
from /config/initializersfinally put
<%= f.cktext_area :body %>
视图文件中的这一行。Use following things it working for me but you should have account on Amazon for s3 storage and correct endpoint you can refer following
`
comment this line
require "ckeditor/orm/active_record"
from /config/initializersfinally put this line in
<%= f.cktext_area :body %>
view file.除了 Zaparka 的响应之外,我还必须删除 #{Rails.root},因为我收到了统一的常量错误。所以我输入了“/config/s3.yml”,这样就成功了。
In addition to Zaparka's response, I had to remove #{Rails.root} as I was getting an unitialized constant error. SO instead I put "/config/s3.yml", and that worked.