Forum: Ruby on Rails Saving rich text to the database

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 David (Guest)
on 2009-02-25 15:09
(Received via mailing list)
I've started trying to use the wysihat rich text editor from 37-
signals and everything is going well except that I get an error when
trying to save the text from the enhanced field to the database.  This
is from my log:

Processing InstructionsController#new (for 127.0.0.1 at 2009-02-25
06:04:57) [POST]
  Session ID:
BAh7CCIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
%0ASGFzaHsABjoKQHVzZWR7ADoMY3NyZl9pZCIlMjNkODY3MzA1YTVkMmQ2MTgw
%0AZDdhZTA1Y2I1OTZlZmI6CXVzZXJpCQ%3D%3D--
f732f8aee1da43652706372f3d32f66ce203b19b
  Parameters: {"commit"=>"Create", "instruction"=>
{"description"=>"first\nsecond\nthird"},
"authenticity_token"=>"88c467dd4b6f308ac40ebd2025a5193874f5ac0f",
"action"=>"new", "controller"=>"instructions"}
   [4;36;1mUser Columns (0.004000) [0m    [0;1mSHOW FIELDS FROM
`users` [0m
   [4;35;1mUser Load (0.000000) [0m    [0mSELECT * FROM `users` WHERE
(`users`.`id` = 4)  [0m
   [4;36;1mInstruction Columns (0.003000) [0m    [0;1mSHOW FIELDS FROM
`instructions` [0m
   [4;35;1mSQL (0.000000) [0m    [0mBEGIN [0m
   [4;36;1mInstruction Create (0.000000) [0m    [0;1mINSERT INTO
`instructions` (`start_day`, `title`, `description`, `appointment_id`,
`frequency`) VALUES(NULL, NULL, 'first\nsecond\nthird', NULL, NULL)
[0m
   [4;35;1mSQL (0.063000) [0m    [0mCOMMIT [0m


NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.call):

How do I go about saving text from this field to the database?  Does
it save it as html markup?
92497f51734ed56687928d5fd68d870a?d=identicon&s=25 Sarah Mei (Guest)
on 2009-02-26 02:17
(Received via mailing list)
Couple of questions: first, what happens if you copy and paste the
insert SQL into your database and run it (i.e., are you sure the SQL
works on your db)? Second, what is in your log after the NoMethodError
message?
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 Dave L (Guest)
on 2009-02-26 04:30
(Received via mailing list)
I've been trying to figure this out and I don't think its an issue
with the database.  When the form is submitted, its contents are blank
everytime, so it is not submitting correctly.  I have made a pastie
with my console output, ignore the template error, I am just trying to
get it to submit the contents of the text area:
http://pastie.org/400591.

Has anyone been able to use the wysihat library and successfully save
to the database?
F677fa685a2cfe8aff31f161062db3d3?d=identicon&s=25 Dave L (Guest)
on 2009-02-26 06:24
(Received via mailing list)
Okay I figured it out.  I emailed Josh, the author of the library and
this was his response:

If you using the 0.1 release it should automatically sync the
description textarea and the rich text area.

In on the latest version, I disabled this feature by default because
it was slowing alot of browsers down. So you can manually flush the
content out with "editor.save();". So you could do
onclick="editor.save();" or something like that.

So I also had to make editor a global variable and then I included
editor.save() in :before with
submit_to_remote
This topic is locked and can not be replied to.