camelCase column in postgresql database in rails (ActiveRecord)

Viewed 5177

I have Post model. It has title and body. I want to add short description in there. Although, I know how to do it with snake_case (i.e. short_description), I wonder if there is any way to create a post with camelCase (i.e. shortDescription).

This is my schema.rb file

  create_table "posts", force: :cascade do |t|
    t.datetime "created_at",                     null: false
    t.datetime "updated_at",                     null: false
    t.string   "title"
    t.text     "body"
    t.string   "shortDescription"
  end

I added shortDescription to controller and a form. When I go to posts#create, I get the following error.

undefined method `shortDescription'

For now I am going to rollback the database, and create short_description. It is not a big issue, but because of my curiosity for the technology, I would like to know how to use camelCase. (Maybe someday I need to join the db with camelCased attributes with Rails app).

Any advise is appreciated. Thank you!

2 Answers
Related