Rails Console: reload! not reflecting changes in model files? What could be possible reason?

后端 未结 2 472
天涯浪人
天涯浪人 2020-11-30 01:39

Earlier it was working fine. I have been playing little bit config. So may be i have changed some config unknowingly.

here is config of environment/development.rb

相关标签:
2条回答
  • 2020-11-30 01:53

    reload! only reloads the latest code in the console environment. It does not re-initialize existing objects.

    This means if you have already instantiated any objects, their attributes would not be updated - including newly introduced validations. However, if you create a new object, its attributes (and also validations) will reflect the reloaded code. more here

    0 讨论(0)
  • 2020-11-30 02:11

    Are you reloading the object from the database?

    For example:

    >> a = User.last
    => #<User id: 16, email: "asdfadsf@sdfdsf.com">
    >> reload!
    Reloading...
    => true
    

    'a' won't reflect any changes to your model until you reload it from the db.

    0 讨论(0)
提交回复
热议问题