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 8944359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:00:09+00:00 2026-06-15T12:00:09+00:00

I have a simple Rails 3 model, with an attr_accessor that doesn’t have a

  • 0

I have a simple Rails 3 model, with an attr_accessor that doesn’t have a field in the database, and I need to set it up using fixtures, because of my initialization setup.

But when I try it, I get an error about the unknown column.

Is there another way to do this?

My model:

class Timeslot < ActiveRecord::Base
    attr_accessor :interval
    after_initialize :init

    def init
        self.interval ||= 15
        self.start_time ||= Time.local(0, 1, 1)
        self.end_time = self.start_time.advance :minutes => self.interval
    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-15T12:00:11+00:00Added an answer on June 15, 2026 at 12:00 pm

    Fixtures add data directly into the database. If you want to pass data to a model instead, consider using factories (Factory Girl is a good library).

    You may already have a big investment in fixtures, but factories are well worth a look.

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

Sidebar

Related Questions

I have a simple url that will toggle one field in my search model.
I have a Rails simple application that has two main models. A person model
I have a very simple Rails app with a very simple relational database: Category
I have made a simple Rails application that allows people to comment on posts.
I've created a simple rails app that has a people and a notes model.
I have a simple Rails 3 example application that I'm trying to work out
I'm writing a simple Rails model called Person that has_many :phone_numbers and I'm trying
I have a simple model for suggestions in my Rails 3 application. I am
I have simple rails application. Create, delete, edit posts. And I need to rate
In my Rails 3 application I have a simple model relationship which is as

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.