Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7842447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:19:26+00:00 2026-06-02T16:19:26+00:00

I have a table with one column that is of text type. There’s a

  • 0

I have a table with one column that is of text type.
There’s a small string in it that should be serialized as an array

serialize :image_urls, Array 

There are times when SQL is just faster for inserting data.
When this is the case, I do the insert as a string

["image1.jpg", "image2.jpg"]

Since I’m inserting a string my Rails app crashes when it tries to read the data, with the following error message:

Attribute was supposed to be a Array, but was a String

Is there a way to not have this error thrown, or to catch it and convert the data?

I mean converting the string to an array is just a simple call, so, this should be easy. I just don’t know where, or how to accomplish it.


I sort of think overriding object_from_yaml, but I’m not sure where to do this work.

Am I in the right track?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:19:26+00:00Added an answer on June 2, 2026 at 4:19 pm

    From the fine manual:

    serialize(attr_name, class_name = Object)
    […] The serialization is done through YAML.

    So the column should contain a YAMLized version of your image_urls but '["image1.jpg", "image2.jpg"]' is not a YAML array. If you want to muck around with the raw serialized data then you should use something like

    ["image1.jpg", "image2.jpg"].to_yaml
    # ---------------------------^^^^^^^
    

    to generate the string.

    Or better, stop using serialize altogether in favor of a separate table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TABLE elements with one COLUMN number, type SMALLINT that contains numbers
I have a table that containts a set of columns one of it is
I have a table of 3-4 columns, the central one being task names that
Screenshot mockup: http://tinypic.com/r/y2qex/5 Problem: I have a table that has 53 columns; one for
I have one datatable. In that table I have columns named [Total Day], [Present
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have a table with one column and four rows. Each tr has a
I have an HTML table with one column being email addresses; spambot issues aside,
I have a table of many values where one column has the WO Number,
i have a large mysql database table in which one column contains values ranging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.