Rails,CKEditor,PostgreSQL,使用Carrierwave上传图片

时间:2013-05-24 22:07:01

标签: ruby-on-rails-3 postgresql ckeditor carrierwave

当我尝试将图像插入我的博客时,我选择上传标签并选择我的文件和Send it to Server。然后在URL选项卡中选择Browse Server,我收到以下错误:

ActiveRecord::StatementInvalid in Ckeditor::AttachmentFilesController#index

PG::Error: ERROR:  relation "ckeditor_assets" does not exist
LINE 5:              WHERE a.attrelid = '"ckeditor_assets"'::regclas...
                                    ^
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                 pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
          FROM pg_attribute a LEFT JOIN pg_attrdef d
            ON a.attrelid = d.adrelid AND a.attnum = d.adnum
         WHERE a.attrelid = '"ckeditor_assets"'::regclass
           AND a.attnum > 0 AND NOT a.attisdropped
         ORDER BY a.attnum

任何想法?

修改

我跳过上述问题的迁移。但我还是无法上传文件。我收到了这个错误:

Started POST "/ckeditor/attachment_files? CKEditor=blog_entry_body&CKEditorFuncNum=1&langCode=en" for 127.0.0.1 at 2013-05-24 18:10:29 -0500
Processing by Ckeditor::AttachmentFilesController#create as HTML
Parameters: {"upload"=>#<ActionDispatch::Http::UploadedFile:0x000000047e3c28 @original_filename="me.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"upload\"; filename=\"me.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<Tempfile:/tmp/RackMultipart20130524-27036-1g7t9yd>>, "CKEditor"=>"blog_entry_body", "CKEditorFuncNum"=>"1", "langCode"=>"en"}
WARNING: Can't verify CSRF token authenticity
User Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."remember_token" = 'M96bQAv-NGdidsn7hypOJA' LIMIT 1
(0.2ms)  BEGIN
(0.3ms)  ROLLBACK
Rendered text template (0.0ms)

看起来好像发生在Ckeditor::AttachmentFilesController#create。但是当我安装CKEditor gem时,我没有看到这个控制器生成。我在另一篇文章中发现我必须skip_before_filter :verify_authenticity_token,但就像我说的那样,我没有看到Ckeditor::AttachmentFilesController#create

1 个答案:

答案 0 :(得分:0)

SQL是ActiveRecord用来确定PostgreSQL表的结构,从而得出ActiveRecord::Base子类的属性。 &#34;关系不存在&#34;错误意味着您有一个CkeditorAsset ActiveRecord类(因此ckeditor_assets表名)但不是ckeditor_assets表。您在某个地方错过了迁移,也许有一个生成器用于初始化您忘记运行的CKEditor插件。