2010-04-18 194 views
2

我剛成功在我的rails博客中使用installedWysiHat。似乎'添加圖片'功能無法正常工作,它成功地允許我從桌面上查找並選擇一張圖片,但在點擊保存,它什麼都不做。WYSIHAT'resonds_to_parent「未定義的方法 - Ruby on Rails

我也有安裝成功回形針,並且可以在WYSIHAT表單域之外附加圖像的記錄。

任何想法?(讓我知道如果我需要張貼任何代碼)。

此外,WysiHat引擎使用facebox,不知道這是否相關。

UPDATE:增加了服務器日誌,看起來像回形針正在保存它,所以不知道還有什麼問題。

Processing PostsController#update (for 127.0.0.1 at 2010-04-23 16:42:14) [PUT] 
    Parameters: {"commit"=>"Update", "post"=>{"body"=>"<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>", "title"=>"Rails Code for Search"}, "authenticity_token"=>"hndm6pxaPLfgnSMFAmLDGNo86mZG3XnlfJoNOI/P+O8=", "id"=>"105"} 
    Post Load (0.2ms) SELECT * FROM "posts" WHERE ("posts"."id" = 105) 
    Post Update (0.3ms) UPDATE "posts" SET "updated_at" = '2010-04-23 21:42:14', "body" = '<p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>' WHERE "id" = 105 
[paperclip] Saving attachments. 
Redirected to http://localhost:3000/posts/105 
Completed in 12ms (DB: 0) | 302 Found [http://localhost/posts/105] 

更新2 我安裝ImageMagic,現在我碰到下面的錯誤。

Processing WysihatFilesController#index (for 127.0.0.1 at 2010-04-23 23:27:57) [GET] 
    Parameters: {"editor"=>"post_body_editor"} 
    WysihatFile Load (0.3ms) SELECT * FROM "wysihat_files" 
Rendering wysihat_files/index 
Rendered wysihat_files/_form (1.9ms) 
Completed in 4ms (View: 3, DB: 0) | 200 OK [http://localhost/wysihat_files/?editor=post_body_editor] 


Processing WysihatFilesController#create (for 127.0.0.1 at 2010-04-23 23:28:09) [POST] 
    Parameters: {"commit"=>"Save changes", "wysihat_file"=>{"file"=>#<File:/var/folders/F3/F3ovLEb1EMW4aZ5nsRvRlU+++TI/-Tmp-/RackMultipart20100423-43326-1mzeb3s-0>}, "authenticity_token"=>"IHF9Ghz6gYuAeNOUYhna+O0A4WrDbm4iha4Tsavu97o="} 

NoMethodError (undefined method `responds_to_parent' for #<WysihatFilesController:0x10352a2c0>): 
    vendor/gems/wysihat-engine-0.1.12/app/controllers/wysihat_files_controller.rb:10:in `create' 

Rendered rescues/_trace (25.2ms) 
Rendered rescues/_request_and_response (0.3ms) 
Rendering rescues/layout (internal_server_error) 

更新3 閱讀以下我想,也許我很想念我的Post模型的東西註釋之後。這是模型的代碼。

class Post < ActiveRecord::Base 

    has_attached_file :photo 
    validates_presence_of :body, :title 
    has_many :comments, :dependent => :destroy 
    has_many :tags, :dependent => :destroy 
    has_many :ugtags, :dependent => :destroy 
    has_many :votes, :dependent => :destroy 
    belongs_to :user 
    after_create :self_vote 
     def self_vote 
     # I am assuming you have a user_id field in `posts` and `votes` table. 
     self.votes.create(:user => self.user) 
     end 

    cattr_reader :per_page 
    @@per_page = 10 

end 

回答

0

好吧,看起來像這是一個responds_to_parent錯誤。出於某種原因,我的rails版本不會讓我運行腳本/生成安裝的任何部分。它表示許可被拒絕。我只需運行gem install responds_to_parent就可以了。 Wysihat有點時髦,但現在會工作。

0

試試wysihat引擎。它使用回形針。它適用於我的應用程序。

http://github.com/80beans/wysihat-engine

有一些問題雖然。首先,如果您創建鏈接,則無法取消鏈接。在wysihat-engine JavaScript文件中需要做一些小的調整。將回來與您的補丁。如果你能在那時弄清楚......太棒了! :)

Btw。我不認爲wysihat使用facebox。 wysihat引擎的確如此。查看js文件中的取消鏈接部分。

+0

我確實使用了80beans的引擎。那是我安裝的那個。在識別要上傳的文件後單擊保存時,什麼都不會發生。 – bgadoci 2010-04-18 16:59:37

+0

它確實有效。我現在明白你的問題。選擇文件上傳後,它會顯示爲面部框中的鏈接。然後您必須單擊該鏈接才能將圖像添加到編輯器中。一旦添加到編輯器中,您可以四處移動,根據需要縮放圖像,然後保存。圖像默認保存在(app目錄)/ public/system/files目錄中。 – 2010-04-19 03:08:14

+0

Btw你創建了一個數據庫,並做了所有必要的遷移?如果不是,你不能指望它能夠保存。 – 2010-04-19 03:09:09

0

也許你需要安裝ImageMagick或其他圖像處理插件。無論如何,按照Ryan Bates的RailsCast,你不會出錯:http://railscasts.com/episodes/134-paperclip

+0

試圖立即安裝imagemagick。不容易。也許這是問題,因爲我沒有安裝它。這是有道理的。 – bgadoci 2010-04-24 02:45:29

+0

ImageMagick安裝並獲得另一個錯誤。發佈在更新的問題。 – bgadoci 2010-04-24 04:38:26

+0

你應該檢查一下:http://khamsouk.souvanlasy.com/articles/ajax_file_uploads_in_rails_using_attachment_fu_and_responds_to_parent – digitalWestie 2010-04-24 20:06:44

相關問題