Rails控制台:重新加载!没有反映模型文件中的更改?可能是什么原因? [英] Rails Console: reload! not reflecting changes in model files? What could be possible reason?
问题描述
之前,它工作正常。我一直在玩一些配置。所以可能是我在不知不觉中更改了一些配置。
Earlier it was working fine. I have been playing little bit config. So may be i have changed some config unknowingly.
这是environment / development.rb的配置。
here is config of environment/development.rb
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# migration prefix with sequence #s
config.active_record.timestamped_migrations = false
#time zone
config.time_zone = 'UTC'
这是application的配置部分.rb
Here is config section of application.rb
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
config.active_record.schema_format = :sql
当我重新加载时!在Rails控制台上,它返回true
when i run reload! on rails console it return true
推荐答案
重新加载!
仅重新加载最新的控制台环境中的代码。不会重新初始化现有对象。
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
这篇关于Rails控制台:重新加载!没有反映模型文件中的更改?可能是什么原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!