Rails 3.1 ckeditor [英] Rails 3.1 ckeditor
问题描述
所以我只是试图在rails安装ckeditor,但它看起来不像它的工作。
这是我做的
将这些行添加到我的gemfile中
gemckeditor,〜>
gempaperclip
然后捆绑安装并运行
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')
但是,我得到的是两个textareas没有任何编辑能力。
我做错了什么?
第1步:添加 gem'paperclip'
和 gemckeditor
第2步:捆绑安装。
第3步: rails generate ckeditor:install --orm = active_record --backend = paperclip
第4步:在application.rb中放置 config.autoload_paths + =%W(#{config.root} / app / models / ckeditor) c
步骤5:放置 mount Ckeditor :: Engine => / ckeditor
(如果尚未显示)并运行 db:migrate
STEP 6:打开 application.html.erb
,并将此<%= javascript_include_tag'ckeditor / ckeditor.js'%>
< script type =text / javascript ; $(document).ready(function(){
if($('textarea')。length> 0){
var data = $('textarea');
.each(data,function(i){
CKEDITOR.replace(data [i] .id);
});
}
});< / script>
STEP 8:重新启动WEBrick服务器。
就是这样。
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?
STEP 1: Add gem 'paperclip'
and gem "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 run db: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
<script type="text/javascript">$(document).ready(function() {
if ($('textarea').length > 0) {
var data = $('textarea');
$.each(data, function(i) {
CKEDITOR.replace(data[i].id);
});
}
});</script>
STEP 8: Restart the WEBrick SERVER. That's it.
这篇关于Rails 3.1 ckeditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!