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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:02:00+00:00 2026-06-14T02:02:00+00:00

Say I have in Rails 3.1: class Category < ActiveRecord::Base has_many :items end class

  • 0

Say I have in Rails 3.1:

class Category < ActiveRecord::Base
  has_many :items
end

class Item < ActiveRecord::Base
  belongs_to :category
end

I’d like to do something

cat=Category.find(1)
cat.items.is_enabled=true
cat.save

but can’t and need to set each via a loop. Is there some way to just set these all at once?

thx

  • 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-14T02:02:03+00:00Added an answer on June 14, 2026 at 2:02 am

    try

     cat.items.update_all(:is_enabled => true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have: class Foo < ActiveRecord::Base has_many :bar end class Bar <
Let's say I have two ActiveRecord models: LineItem and Article. class LineItem < ActiveRecord::Base
In a Ruby on Rails app, say I have an Item and an Order
Let's say I have an ActiveRecord called Apples, and I want a class method
Let's say I have a nested resource like in the Rails guide example: http://guides.rubyonrails.org/routing.html#nested-resources
Let's say I have the following threading in my Rails web application: class MyController
I have a Vehicle model: class Vehicle < ActiveRecord::Base validates_presence_of :num_of_wheels validates_presence_of :make validates_presence_of
I am having a problem with structuring rails application. Let's say that I have
I have a couple of models in a Rails app. Let's say it's Products
Lets say have this immutable record type: public class Record { public Record(int x,

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.