DB only holds the last data

14 views
Skip to first unread message

Anderson Pioner

unread,
Feb 4, 2016, 8:55:05 PM2/4/16
to RailsInstaller
Hello, I'm facing an issue with railsinstaller running on windows 10.

1) I've created a all new app.
2) I've created a all new model and migration file.
3) Then I've runned 'rails console'
4) I've saved a new data to the DB doing: 'mymodel.save'
5) I've saved a second new data to the DB doing: 'mymodel.save'
6) I've run Mymodel.all

What surprise: only the last data was on the DB.

I'm using sqlite 3
Ruby 2,0

Any suggestion to solve my issue?


Dušan D. Majkić

unread,
Feb 5, 2016, 4:17:31 AM2/5/16
to railsin...@googlegroups.com
> 4) I've saved a new data to the DB doing: 'mymodel.save'

Method mymodel.save return false if saving for some reason was unsuccessful.
If you don't react to false result - your mymodel.save silently fails.

Try with mymodel.save! which will raise exception if something is wrong.
Reply all
Reply to author
Forward
0 new messages