activerecord - Changing enum value in Rails without saving model -


how change enum value without saving model database yet?

the documentation activerecord::enum indicates methods conversation.active! , conversation.status = "archived" equivalent doing conversation.update! status: 1, whereas i'm getting attributes simple_form form, , don't want save model until of attributes have been set, otherwise model won't valid.

the bang version of method - conversation.active! save database immediately.

the other way - conversation.status = "archived" not, , require explicit conversation.save! afterwards. so, that's method you're after.

(btw, rails console handy testing stuff this, , show exact sql gets executed bang version of method, execute it)


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -