简体   繁体   English

Ruby on Rails服务器在重新启动之前不会反映对数据库记录的更改

[英]Ruby on Rails server not reflecting changes to database records until restart

If I open the Rails Console and create a new Widget: 如果我打开Rails Console并创建一个新的Widget:

>> widget = Widget.new
>> widget.name = "Whatever"
>> widget.save

The Widget saves without errors. 窗口小部件保存无误。 However, when I run: 但是,当我运行时:

>> Widget.all

This new Widget does not appear in the returned list of records. 此新的小部件不会出现在返回的记录列表中。 However, if I restart the Rails Console and run the same command again: 但是,如果我重新启动Rails Console并再次运行相同的命令:

>> Widget.all

The Widget now appears in the list of records. 窗口小部件现在显示在记录列表中。 Why is this happening? 为什么会这样呢? I'm having the same problem with the Rails Server; 我在Rails Server上遇到了同样的问题; if I create or edit a Widget with the scaffold views I generated, those Widgets do not appear in the show view until I restart the Rails Server. 如果我使用生成的支架视图创建或编辑窗口小部件,则在重新启动Rails Server之前,这些窗口小部件不会出现在显示视图中。

By the way, I'm on Windows 7, using RubyMine as my IDE, and using rails 3.2.4 and sqlite3. 顺便说一句,我在Windows 7上,使用RubyMine作为我的IDE,并使用rails 3.2.4和sqlite3。

One of the commenters above recommended I update to rails 3.2.11. 上面的评论者之一建议我更新到Rails 3.2.11。 I updated the version in my Gemfile and ran bundle update and this fixed the issue. 我更新了Gemfile中的版本,并进行了bundle update ,从而解决了该问题。 I don't know which gem or combination of them was the problem before the update. 我不知道是哪个宝石或它们的组合是更新之前的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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