简体   繁体   中英

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

If I open the Rails Console and create a new 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:

>> 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; 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.

By the way, I'm on Windows 7, using RubyMine as my IDE, and using rails 3.2.4 and sqlite3.

One of the commenters above recommended I update to rails 3.2.11. I updated the version in my Gemfile and ran bundle update and this fixed the issue. I don't know which gem or combination of them was the problem before the update.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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