Rails 3.1 ckeditor
所以我只是尝试在 Rails 中安装 ckeditor,但它看起来并不工作。
这是我所做的
将这些行添加到我的 gemfile
gem "ckeditor", "~> 3.6.0"
gem "paperclip"
然后捆绑安装并运行
rails generate ckeditor:install
rails generate ckeditor:models --orm=active_record
添加此文件 tom config/application.rb
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
然后我尝试了此代码:
<%= javascript_include_tag :ckeditor %>
cktext_area_tag("test_area", "Ckeditor is the best")
cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
但是,我得到的只是两个文本区域没有任何编辑能力。它们看起来像普通的文本区域,我所能做的就是擦除和添加文本。
我做错了什么?
So I just tried to install ckeditor in rails, however it doesn't look like its working.
Here is what I did
added these lines to my gemfile
gem "ckeditor", "~> 3.6.0"
gem "paperclip"
Then bundled installed and ran
rails generate ckeditor:install
rails generate ckeditor:models --orm=active_record
Added this file tom config/application.rb
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
And then I tried out this code:
<%= javascript_include_tag :ckeditor %>
cktext_area_tag("test_area", "Ckeditor is the best")
cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
However, all I am getting is two textareas that do not have any editing ability. They look like normal textareas and all I can do is erase and add text.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就像一个魅力,刚刚在 Rails 3.1.rc6 上测试过。还要小心您使用的宝石。截至本文发布时,官方 gem 尚未工作并正在等待拉取请求,因此请务必在您的 gemfile 中使用 fxposter 版本的 gem。
This works like a charm, just tested it on rails 3.1.rc6. Also be cautious of the gem you are using. As of the moment of this post, the oficial gem was not working and was waiting for a pull request, so be sure to use fxposter's version of the gem in your gemfile.
https://github.com/fxposter/rails_3_1_with_ckeditor_and_carrierwave
我和你有同样的设置和同样的问题。通过将 jalagrange 的示例应用程序与我的进行比较,我最终发现问题出在development.rb 中。我必须删除这一行:
此后它对我有用。
I had the same setup as you and the same issue. With jalagrange's example app as a comparison to mine, I eventually found the issue to be in development.rb. I had to remove this line:
It worked for me with after that.
前段时间我在设置的时候也遇到了类似的问题。我最终放弃了宝石。问题是让 ckeditor 在资产管道中运行,但根据浏览器的不同,我得到的结果是混合的(当然 IE 是问题所在)。以下是对我有用的方法:
从他们的网站下载 ckeditor 包并放入 public/ckeditor。
然后,直接包含 javascript 文件。
不太优雅,但它确实有效,而且从那以后就再也没有碰过它。
I had a similar issue when I was setting it up a while ago. I gave up on the gem eventually. The problem was getting ckeditor to behave in the asset pipeline, but I had mixed results depending on the browser (of course IE was the problem). Here is what worked for me:
Download ckeditor package from their site and drop in to public/ckeditor.
Then, directly include the javascript files.
Not exactly elegant, but it worked and haven't had to touch it since.
第 1 步:在 gem 文件中添加
gem 'paperclip'
和gem "ckeditor"
。第 2 步: 捆绑安装。
第3步:
rails生成ckeditor:install --orm=active_record --backend=paperclip
第4步:放置
config.autoload_paths + = %W(#{config.root}/app/models/ckeditor) 在 application.rb
第 5 步: 放置
挂载 Ckeditor::Engine => “/ckeditor”
(如果尚不存在)并运行db:migrate
第 6 步: 打开
application.html.erb
并将其放置在标头中的<%= javascript_include_tag 'ckeditor/ckeditor.js' %>
。第 7 步: 将其放在
application.html.erb
的页脚(body 标记上方)中第 8 步: 重新启动 WEBrick 服务器。
就是这样。
STEP 1: Add
gem 'paperclip'
andgem "ckeditor"
in your gemfile.STEP 2: Bundle Install.
STEP 3:
rails generate ckeditor:install --orm=active_record --backend=paperclip
STEP 4: Place
config.autoload_paths += %W(#{config.root}/app/models/ckeditor) in application.rb
STEP 5: Place
mount Ckeditor::Engine => "/ckeditor"
if not present already and rundb:migrate
STEP 6: Open
application.html.erb
and place this<%= javascript_include_tag 'ckeditor/ckeditor.js' %>
in header.STEP 7: Place this in footer(above the body tag) in
application.html.erb
STEP 8: Restart the WEBrick SERVER.
That's it.