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

  • SEARCH
  • Home
  • 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 9222497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:50:48+00:00 2026-06-18T03:50:48+00:00

According to the Rails docs http://api.rubyonrails.org/classes/ActiveRecord/Base.html , I can store an array in a

  • 0

According to the Rails docs http://api.rubyonrails.org/classes/ActiveRecord/Base.html, I can store an array in a database using the serialize method

 class User < ActiveRecord::Base
      serialize :preferences, Hash
    end

    user = User.create(:preferences => %w( one two three ))

In my dinky application, I seralized the answers column of the Question model, because there will be multiple possible answer choices

class Question < ActiveRecord::Base
  attr_accessible :question, :link, :answers, :correctanswers

  serialize :answers

end

Trying to seed the database to test it, I did this…

Question.create!( question: "what is R's favorite color", answers: "a" => %w( red green blue ), correctanswer: "blue", link => "http://janesblog.com")

However, the rake db.seed aborted with all sorts of errors suggesting I have the syntax wrong

/Users/mm/Sites/ljk/db/seeds.rb:17: syntax error, unexpected tASSOC, expecting ')'
...avorite color", answers: "a" => %w( red green blue ), correc...
...                               ^
/Users/mm/Sites/ljk/db/seeds.rb:17: syntax error, unexpected ',', expecting $end
...s: "a" => %w( red green blue ), correctanswer: "blue", link ...

Can anyone assist with the correct syntax?
Table

class CreateQuestions < ActiveRecord::Migration
  def change
    create_table :questions do |t|

      t.string :question
      t.string :link
      t.text   :answers
      t.string :correctanswer


      t.timestamps
    end
  end
end
  • 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-18T03:50:49+00:00Added an answer on June 18, 2026 at 3:50 am

    I think you want:

    Question.create!(
      question: "what is R's favorite color",
      answers: %w( red green blue ),
      correctanswer: "blue",
      link: "http://janesblog.com"
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html , if I write a Rails 3 plugin and I want
According to Rails doc: http://guides.rubyonrails.org/migrations.html Active Record tracks which migrations have already been run
Rails has beautiful documentation on their guides and their website: http://guides.rubyonrails.org/association_basics.html I am taking
According to API Dock, ActiveRecord::Associations::AssociationProxy is now deprecated or moved. I'm curious as to
According to the docs, the jquery-ujs Installation is as easy as adding gem 'jquery-rails',
According to the Rails API (snippet below), the optimal way to receive mail is
I'm wondering if there's any way for a Rails asset to vary according to
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to this Rails guide , if you create a fixture, it becomes available
I'm having to build a rails app around a legacy PostgreSQL database that doesn't

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.