views:

283

answers:

3

I just successfully installed WysiHat in my rails blog. Seems that the 'add a picture' feature is not working. It successfully allows me to find and select a picture from my desktop but upon clicking save, it does nothing.

I also have Paperclip successfully installed and can attach images to records outside the WYSIHAT form field.

Any ideas? (let me know if I need to post any code).

Also, WysiHat-engine uses facebox, not sure if that is relevant.

UPDATE: Added Server Log, looks like paperclip is saving it so not sure what else is going wrong.

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]

UPDATE 2 I installed ImageMagic and now I get the following error.

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)

Update 3 After reading a comment below I am thinking that perhaps I am missing something in my Post model. Here is the code for the model.

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
A: 

Try the wysihat-engine. It uses paperclip. And it works well on my app.

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

There are some problems though. First is that if you create a link you cannot unlink it. There is a small tweak that you need to do in the wysihat-engine javascript file. Will come back to you with the patch. If you can figure it out by then.. great! :)

Btw. i dont think wysihat uses facebox. The wysihat-engine does. Check out the unlink portion in the js file.

Shripad K
I did use that engine from 80beans. That is the one that I have installed. When clicking save after identifying file to upload, nothing happens.
bgadoci
It does work. I understood your problem now. After you choose your file for upload it shows up as a link in the facebox. You then have to click the link to add the image to the editor. Once its added to the editor you can move around, scale the image to your needs and then save. The image gets by default stored in the (app directory)/public/system/files directory.
Shripad K
Btw did you create a database and did all the necessary migrations?? If not you can't expect it to save.
Shripad K
If you still are skeptical i can host it on heroku and add you as a collaborator. So you can pull my code to see if there is any difference. But I'll do all this provided none of my answers work. :)
Shripad K
Not skeptical at all and it looks great. My problem is that when I add the file by the facebox popup link, it doesn't add it to the post. It just sits there. Does that make sense?
bgadoci
It still doesn't make sense. Can you host your app on heroku and add me as a collaborator? did you try the wysihat-engine-demo? http://github.com/80beans/wysihat-engine-demoBtw. This is all you have to put in your views form_for: `<p>` `<%= f.label :content %><br />` `<%= f.wysihat_editor :content %>` `</p>`
Shripad K
sounds good. I will be posting to heroku in the next couple of days and will comment here when I do so you can have a look. Thanks for the help.
bgadoci
Sure :) Send me a mail.
Shripad K
@paddy, send me an email to [email protected] w/ your email address so I can add you as a collaborator on heroku. (also note that I am having some problems with the app running on heroku because of and error message, I listed it in my recent questions).
bgadoci
Also make sure your filesystem where your app exists is not read only and that it can store uploaded files.
Shripad K
@bgadoci. I have hosted the app myself. The basic wysihat-engine-demo app that is. It doesn't work on heroku as it has a read only filesystem. I have to use amazon S3 to store user uploaded static files, which i haven't yet created. But you can clone my app and then test it locally. git clone `[email protected]:wysihatenginedemo.git -o heroku`. For the upload, the facebox is screwed up. Don't press "Save changes". Rather once you upload a link it shows up in the facebox. Just click on the link. It adds it to your editor.
Shripad K
The facebox thing still isn't working. Tried your recommendation and it still is giving me the error at the top. I think there is a problem with my model or associations.
bgadoci
Ok. Could you get your app hosted on heroku? i would suggest you first try the wysihatenginedemo as it is. Did you clone my app? It works locally on your machine. By tonight i will put up screenshots too showing what you should get. Do give it a try. `git clone [email protected]:wysihatenginedemo.git -o heroku`
Shripad K
A: 

Perhaps you need to install ImageMagick or some other image manipulation plugin. Anyway, follow Ryan Bates' RailsCast and you won't go wrong: http://railscasts.com/episodes/134-paperclip

ro
Trying to install imagemagick right now. Not easy. Perhaps this is the problem as I did not have it installed. That would make sense.
bgadoci
ImageMagick installed and getting another error. Posted in update to question.
bgadoci
You should check this out: http://khamsouk.souvanlasy.com/articles/ajax_file_uploads_in_rails_using_attachment_fu_and_responds_to_parent
ro
A: 

Ok, so looks like this was a responds_to_parent error. For some reason my version of rails wouldn't let me run the script/generate wysihat part of the installation. It said that permission was denied. I simply ran gem install responds_to_parent and all is well. Wysihat is a bit funky but will work for now.

bgadoci