简体   繁体   中英

Rails / Active Record 5.0.0 set id manually before create

I'm connecting a Rails application to another database and can't change the schema. This other database has a NOT NULL constraint on the id field for all of its tables (using uuid for id's).

I'm trying to assign an id manually in a before_create but it seems the attribute is protected.

Any way around this?

Rails 5.0.0

将uid字段添加到新数据库并使用find_by(uid: uid)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM