Rails 控制台:重新加载!不反映模型文件中的更改?可能的原因是什么?
早些时候它运行良好。我一直在玩一点配置。所以可能我在不知不觉中改变了一些配置。
这是环境/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'
这是
# 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
我运行重新加载时application.rb的配置部分!在 Rails 控制台上它返回 true
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
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'
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
when i run reload! on rails console it return true
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
reload!
仅在控制台环境中重新加载最新的代码。它不会重新初始化现有对象。这意味着如果您已经实例化了任何对象,它们的属性将不会更新 - 包括新引入的验证。但是,如果您创建一个新对象,其属性(以及验证)将反映重新加载的代码。
更多信息
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
您是否从数据库重新加载对象?
例如:
“a”不会反映模型的任何更改,直到您从数据库重新加载它。
Are you reloading the object from the database?
For example:
'a' won't reflect any changes to your model until you reload it from the db.