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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:51:16+00:00 2026-05-23T06:51:16+00:00

I have entries table with a content field which might contain a lot of

  • 0

I have entries table with a content field which might contain a lot of text. In most cases I don’t need to access that field, so it seems to be a big waste of resources to every time load a huge amount of unused data from the database (select * from entries where id = 1).

How could I specify the default_scope, that all the fields apart from content would be loaded from database?

  • 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-05-23T06:51:17+00:00Added an answer on May 23, 2026 at 6:51 am

    Assuming Rails 3 and a schema that looks like this:

    create_table "entries", :force => true do |t|
      t.string   "title"
      t.text     "content"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
    

    You can use the select method to limit the fields that are returned like this:

    class Entry < ActiveRecord::Base
      default_scope select([:id, :title])
    end
    

    In the rails console, you should see something like this:

    puts Entry.where(:id => 1).to_sql  # => SELECT id, title FROM "entries"  WHERE "entries"."id" = 1
    

    When you do want to select all of the fields, you can use the unscoped method like this:

    puts Entry.unscoped.where(:id => 1).to_sql  # => SELECT * FROM "entries"  WHERE "entries"."id" = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dashboard in my website which contain some entries in table, each
I have a CQL 3 CF CREATE TABLE entries ( id text, va text,
I have table and this table contain result column with some entries. I just
I have a mysql table with about 2,000,000 entries, with a primary key which
Say I have a database table with three fields: id, content and timestamp. Entries
I have a table that contains common entries in two columns. For Example: Column1
I have a table that is a collection entries as to when a user
I have a table that contains log entries for a program I'm writing. I'm
I have a Fusion Table of about 1000 entries, and I show them on
I have a MySQL table that holds many entries with repeated IDs (for various

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.