Return Column Model

I have a rails program that accesses an old database with columns from an UPPERCASE table.

I want to be able to enter user.firstname, not user.FIRSTNAME

How to get ActiveRecord to get a string version of these column names to allow me to use string attributes in the model?

+3
source share
2 answers

It may be easier to change column names using migrations. Otherwise, you will have to change the gems that you use, and then pack them in the vendor / gems so that they worsen.

  • script / generate migration down_case_table_names_and_columns
  • record migration
  • rake db: migrate

For each table:

rename_table :OLD_NAME, :new_name

For each column:

rename_column :COLUMN_NAME, :column_name

, , fyi - . , , . .

0

Source: https://habr.com/ru/post/1789684/


All Articles