I have file manager in my app and I need to upload the file to the folder by the name of models.I change the :url and :path options like below: class Ckeditor::Picture < Ckeditor::Asset has_attached_file :data, :url => "/ckeditor_assets/ pictures/:id/:style_:basename.:extension", :path => ":rails_root/public/ckeditor_assets/ pictures/:id/:style_:basename.:extension", :styles => { :content => ''575>'', :thumb => ''80x80#'' } validates_attachment_size :data, :less_than=>2.megabytes I have defined the interpolates in config/initializers/paperclip.rb like below: Paperclip.interpolates :pagename do |attachment, style| attachment.instance.page_name end Paperclip.interpolates :basename_style do |attachment, style| if style.to_s=="original" attachment.original_filename.split(".")[0] else "#{attachment.original_filename.split(".")[0]}-#{style}" end end Then Add a method named page_name in Ckeditor::Asset: class Ckeditor::Asset < ActiveRecord::Base def page_name assetable.page_name end Now I think it will work after added the :swf_params option: <%f.cktext_area :content, :height=>''200px'', :swf_params=>{:assetable_type => ''Article'', :assetable_id => @article.id} %> But very disappointed with result,it doesn''t work.I found the error cause by the code in the file vendor/plugins/rails-ckeditor/lib/ ckeditor/version.rb: output_buffer << javascript_tag("if (CKEDITOR.instances[''#{element_id}'']) { alert(''yes'') CKEDITOR.remove(CKEDITOR.instances[''#{element_id}'']);} else alert(''No'') CKEDITOR.replace(''#{element_id}'', { #{ckeditor_applay_options(ckeditor_options)} });") The below js in the page is generated by the code and the condition if (CKEDITOR.instances[''article_content_editor'']) alway returns false, so the :swf_params options is alway of no avail: <script type="text/javascript"> //<![CDATA[ if (CKEDITOR.instances[''article_content_editor'']) { alert(''yes'') CKEDITOR.remove(CKEDITOR.instances[''article_content_editor'']);} else alert(''No'') CKEDITOR.replace(''article_content_editor'', { filebrowserBrowseUrl: ''/ckeditor/files'',language: ''en'',width: ''100%'',filebrowserUploadUrl: ''/ckeditor/create/file'',height: ''200px'',filebrowserImageBrowseUrl: ''/ckeditor/ images'',filebrowserImageUploadUrl: ''/ckeditor/create/ image'',swf_params: { assetable_type: ''Article'',assetable_id: 901130968 } }); //]]> </script> How to fix this question? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
jaron
2011-Mar-23 18:57 UTC
Re: :swf_params doesn''t work in the newest rails-ckeditor version
I forgot wrote the plugin I using is rails-ckeditor. sorry ^_^ On Mar 24, 2:51 am, jaron <inepa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have file manager in my app and I need to upload the file to the > folder by the name of models.I change the :url and :path options like > below: > class Ckeditor::Picture < Ckeditor::Asset > has_attached_file :data, > :url => "/ckeditor_assets/ > pictures/:id/:style_:basename.:extension", > :path => ":rails_root/public/ckeditor_assets/ > pictures/:id/:style_:basename.:extension", > :styles => { :content => ''575>'', :thumb => > ''80x80#'' } > > validates_attachment_size :data, :less_than=>2.megabytes > > I have defined the interpolates in config/initializers/paperclip.rb > like below: > Paperclip.interpolates :pagename do |attachment, style| > attachment.instance.page_name > end > > Paperclip.interpolates :basename_style do |attachment, style| > if style.to_s=="original" > attachment.original_filename.split(".")[0] > else > "#{attachment.original_filename.split(".")[0]}-#{style}" > end > end > > Then Add a method named page_name in Ckeditor::Asset: > class Ckeditor::Asset < ActiveRecord::Base > def page_name > assetable.page_name > end > > Now I think it will work after added the :swf_params option: > <%> f.cktext_area :content, :height=>''200px'', :swf_params=>{:assetable_type > => ''Article'', :assetable_id => @article.id} %> > > But very disappointed with result,it doesn''t work.I found the error > cause by the code in the file vendor/plugins/rails-ckeditor/lib/ > ckeditor/version.rb: > output_buffer << javascript_tag("if > (CKEDITOR.instances[''#{element_id}'']) { > alert(''yes'') > CKEDITOR.remove(CKEDITOR.instances[''#{element_id}'']);} else > alert(''No'') > CKEDITOR.replace(''#{element_id}'', > { #{ckeditor_applay_options(ckeditor_options)} });") > > The below js in the page is generated by the code and the condition if > (CKEDITOR.instances[''article_content_editor'']) alway returns false, so > the :swf_params options is alway of no avail: > <script type="text/javascript"> > //<![CDATA[ > if (CKEDITOR.instances[''article_content_editor'']) { > alert(''yes'') > > CKEDITOR.remove(CKEDITOR.instances[''article_content_editor'']);} else > alert(''No'') > CKEDITOR.replace(''article_content_editor'', > { filebrowserBrowseUrl: ''/ckeditor/files'',language: ''en'',width: > ''100%'',filebrowserUploadUrl: ''/ckeditor/create/file'',height: > ''200px'',filebrowserImageBrowseUrl: ''/ckeditor/ > images'',filebrowserImageUploadUrl: ''/ckeditor/create/ > image'',swf_params: { assetable_type: ''Article'',assetable_id: > 901130968 } }); > //]]> > </script> > > How to fix this question?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.