4

In development I used sqlite3 and I was writing a blog application. So for the blog articles, I had datatype text which worked fine. I was able to write really long articles, never had a problem. Switch over to production using MySQL and now my articles are getting truncated after around 250 characters.

Does anyone know what I need to do and/or change to get MySQL to behave like sqlite3 was, allowing really large bodies of text?

Thank you.

db/schema.rb:

ActiveRecord::Schema.define(:version => 20110307222323) do

  create_table "articles", :force => true do |t|
    t.integer  "user_id"
    t.string   "title"
    t.string   "body"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.integer  "category_id"
    t.string   "url"
  end
end
3
  • show us some code and mysql table dump, please. Commented Apr 11, 2011 at 6:15
  • 2
    Are you using t.string :your_field instead of t.text :your_field in the migration file? Commented Apr 11, 2011 at 6:18
  • wow, so sorry to waste your guys time, i had just recently rewrote the app, and made that mistake second time around. Soooo sorry guys, thanks anyways though! Commented Apr 11, 2011 at 6:33

2 Answers 2

7

May be you should replace

t.string   :body

with

t.text   :body
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I think this is right, Rails treats a "string" as a "varchar(255)" for mysql. Using "text" will allow more characters.
0

You must to change:

 t.text :body #change here

You can find more information about data type comparisons here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.