In ActiveRecord, how to get the name of primary key(s)?
You can call YourModel.arel_table.primary_key.name
. Or better yet, YourModel.primary_key
.
Model.primary_key
seems to work for me.
You can call YourModel.arel_table.primary_key.name
. Or better yet, YourModel.primary_key
.
Model.primary_key
seems to work for me.