开发者

My model is only saving some of the information

开发者 https://www.devze.com 2023-02-15 04:58 出处:网络
This is a simple rails form using CKeditor. I\'m saving the content, it appears in the Update. pp params[:email][\"body\"]

This is a simple rails form using CKeditor.

I'm saving the content, it appears in the Update.

pp params[:email]["body"]
"<br />\r\nheyyy<br />\r\nbut now i am going to save this past 9 lines.<br />\r\ncuz  that&#39;s what this is all about<br />\r\n<开发者_如何学编程;br />\r\nI am crazy like that<br />\r\nc<br />\r\ncrazy<br />\r\ncrazy c<br />\r\ncrazy<br />\r\n<br />\r\nhere is another line..<br />\r\noh@!!&amp;<br />\r\nfa<br />\r\nsdf<br />\r\nas<br />\r\ndf<br />\r\nasd<br />\r\nfa<br />\r\nsdfasdf<br />\r\n"

Then my controller goes like this :

@emails = Email.find(params[:id])

Then! After this is called, I type @emails.body in ruby-debug, and it outputs 1/2 of that! :

@emails.body
"<br />\r\nheyyy<br />\r\nbut now i am going to save this past 9 lines.<br />\r\ncuz  that&#39;s what this is all about<br />\r\n<br />\r\nI am crazy like that<br />\r\nc<br />\r\ncrazy<br />\r\ncrazy c<br />\r\ncrazy<br />\r\n<br />\r\nhere is another line..<br />\r\noh@!!&"

Why would that occur?

The attribute is saved as a string in my database.


You're likely storing it in the database as a varchar instead of text. Depending on the length of the varchar, it will simply truncate the data instead of return an error. You can easily change the column type in a migration:

change_column :my_table, :my_column, :text


What sort of column is body? Could it be that it's a MySQL varchar(255) or something similar that's just being overloaded?


Are you sure you called:

 @emails.save

in the controller ??

If so, try calling:

 @emails.save!

It should raise an error if something goes wrong.

0

精彩评论

暂无评论...
验证码 换一张
取 消