Created
November 4, 2012 15:48
-
-
Save jasonnoble/4012352 to your computer and use it in GitHub Desktop.
Boolean types with sqlite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Test to verify my comment on http://stackoverflow.com/questions/13211811/rails-3-and-sqlite-communications-concerning-boolians/13213314#comment18003546_13213314 | |
| $ rails new sqlite_boolean_test | |
| $ rails generate scaffold User name:string approved:boolean | |
| $ rake db:migrate | |
| $ rails console | |
| >> u = User.create(:name => "Bob", :approved => false) | |
| >> u.approved? | |
| => false | |
| >> u.update_attribute(:approved, true) | |
| => true | |
| >> u = User.find(u.id) | |
| >> u.approved? | |
| >> quit | |
| $ rails dbconsole | |
| sqlite> select * from users; | |
| 1|Bob|t|2012-11-04 15:43:44.086580|2012-11-04 15:44:52.962937 | |
| sqlite> sqlite> update users set approved='f' where id='1'; | |
| sqlite> select * from users; | |
| 1|Bob|f|2012-11-04 15:43:44.086580|2012-11-04 15:44:52.962937 | |
| sqlite> .exit | |
| $ rails console | |
| >> u = User.find_by_name("Bob") | |
| >> u.approved? | |
| => false | |
| >> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment