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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:29:37+00:00 2026-06-14T12:29:37+00:00

I have followed this guide Using Models In Your Migrations . Now I want

  • 0

I have followed this guide Using Models In Your Migrations. Now I want to add a new column called suspect type boolean into Question table, it will have default value is false, and I want to update records have created too. This is my migration file:

class AddSuspectToQuestions < ActiveRecord::Migration
  class Question < ActiveRecord::Base
  end

  def change
    add_column :questions, :suspect, :boolean, default: false
    Question.reset_column_information
    Question.all.each do |question|
      question.update_attributes!(suspect: false)
    end
  end
end

But when I run rake db:migrate, it has error:

==  AddSuspectToQuestions: migrating ==========================================
-- add_column(:questions, :suspect, :boolean, {:default=>false})
   -> 0.3782s
rake aborted!
An error has occurred, this and all later migrations canceled:

Can't mass-assign protected attributes: suspect

I think it needs attr_accesible :suspect, so I added it in Question model, but I still has same error when I run migrate again. I have set this in application.rb too:

config.active_record.whitelist_attributes = true

Anyone has met this problem?

  • 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-14T12:29:38+00:00Added an answer on June 14, 2026 at 12:29 pm

    it doesnt work, since you are overwriting the Question Class in your migration.

    Remove

    class Question < ActiveRecord::Base
    end
    

    and try it again.

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

Sidebar

Related Questions

I am using javascript to make XML to HTML. I have followed this guide:http://www.w3schools.com/xml/xml_to_html.asp
I wanted a sticky footer to I followed this guide: http://www.cssstickyfooter.com/using-sticky-footer-code.html I have in
I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
I have followed this guide to install Solr in TomCat running on Windows Server
I followed this guide here perfectly and have gone through it again but when
Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I have followed this tutorial here as mentioned exactly I now try to run
I'm using Xcode 4.3 and I have followed this user's steps to create the
I have followed the suggestion in this question as I am using Django, I
I have my moodle setup using this guide ( Ubuntu 11.04 ) http://docs.moodle.org/dev/Install_Moodle_On_Ubuntu_with_Nginx/PHP-fpm I

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.