Skip to content

Instantly share code, notes, and snippets.

Created August 30, 2011 08:05
What would you like to do?
# in the controller, very simple model for example, having string ip and string description fields:
DocType.create(:name => request.remote_ip, :description => 'request') # remote_ip is
DocType.create(:name => "", :description => 'string')
# in rails console, only the string assigned object is returned:
ruby-1.9.2-p180 :004 > DocType.find_all_by_name('')
DocType Load (0.7ms) SELECT "doc_types".* FROM "doc_types" WHERE "doc_types"."name" = ''
=> [#<DocType id: 7, name: "", description: "string">]
# sqlite shows 2 records as:
sqlite> select * from doc_types;
# dump shows:
sqlite> .dump doc_types
PRAGMA foreign_keys=OFF;
CREATE TABLE "doc_types" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "description" varchar(255));
INSERT INTO "doc_types" VALUES(6,X'3132372E302E302E31','request');
INSERT INTO "doc_types" VALUES(7,'','string');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment