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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:03:59+00:00 2026-06-12T21:03:59+00:00

Is it possible to specify the column for an attribute? I have something like:

  • 0

Is it possible to specify the column for an attribute? I have something like:

NAME, COUNTRY

The database is quite large and I have over a thousand columns which are capitalized like this. I want to refer to them as so:

attr_accessible :name, :country

Where :name = column NAME. I’d prefer Model.name rather than Model.NAME. It isn’t possible to downcase every column name in the structure file.

  • 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-12T21:04:00+00:00Added an answer on June 12, 2026 at 9:04 pm

    Here is an idea to do the way you preferred.

    Command to generate migration:
    (In my example, im applying this on Posts table. Change according to your table name)

    rails g migrate RenameColumnsOfPosts
    

    Below is the migration up method. Here taking all the column names and for each one I’m applying rename_column to make it downcase.

    class RenameColumnsOfPosts < ActiveRecord::Migration
      def up
         Post.columns.map(&:name).each do |column_name|
            rename_column(:posts, column_name, column_name.downcase)
         end
      end
    
      def down
         #You can do the opposite operation here. Leaving on you
      end
    end
    

    As i didnt run it personally, it might need some changes. So start with it and let me know if facing any problem.

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

Sidebar

Related Questions

Instead of something like lm(bp~height+age, data=mydata) I would like to specify the columns by
Is it possible to specify connection/query timeout for the Oracle database queries? Either on
Is it possible to specify a condition in Count() ? I would like to
Is it possible to specify the classes location like you can in the findbugs
Is it possible to specify the value of a tag or attribute should not
Is it possible to specify a discriminator column from another table? How do I
Id columns can specify a generator. Perfect. However, I have a situation in which
How can you specify a column span in an android's gridview? I have a
Is it possible to specify a column type of unsigned integer in Doctrine 2?
Is it possible to specify include paths for C and C++ in a pkg-config

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.