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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:52:35+00:00 2026-05-22T02:52:35+00:00

My DB tables and field names are in CamelCase. Is it possible to convert

  • 0

My DB tables and field names are in CamelCase. Is it possible to convert those names into snake_case on a fly? To make model methods look pretty?

The app is JRubyOnRails 3.0 / MSSQL DB / ActiveRecord-JDBC-adapter.

  • 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-22T02:52:35+00:00Added an answer on May 22, 2026 at 2:52 am

    @arkadiy,as a matter of fact, I was looking into this just this very day.

    For table names, we of course have the set_table_name method:

    class CamelCasedFoo < ActiveRecord::Base
      set_table_name :CamelCasedTable
    end
    

    For things like primary keys, we have set_primary_key:

    class CamelCasedBar < ActiveRecord::Base
      ...
      set_primary_key "CamelCasedTableID"
    end
    

    And it should be possible to alias funky, legacy column names to something more rails-friendly with alias_attribute:

    class CamelCasedBaz < ActiveRecord::Base
      ...
      alias_attribute :preferred_delivery, :DeliveryFrequency
    end
    

    One key thing to keep in mind is to watch out for any column names that are ruby or rails keywords or magic field names.

    Rails appears to have all that metaprogramming goodness to allow you to work around legacy db table names and columns. You may wish to have a read of Jonathan Hui’s blog post on “Ruby on Rails 3 Model Working with Legacy Database”. And you might want to have a look at the safe_attributes gem.

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

Sidebar

Related Questions

I need to insert data from several tables with all the same field names
The Ruby on Rails convention for database table and field names is snake_case and
Say I have these tables with field names underneath. DailyLeaveLedger dldEmployeeID dldLeaveDate InvoiceHeader invEmployeeID
I have 6 tables with exactly the same structure, the field names go like
I have some data SELECT [field names] FROM [several joined tables] WHERE [some criteria
I've got this database with about 26 tables (field names are the same in
How do i avoid using hardcoded table and field names in entity framework? For
I am having a common field in ten tables with different field name. example:
How can I get the field names of an MS Access database table? Is
I have 5 tables in my Mysql database with t1 with field name like

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.