Alexey Muranov wrote in post #1019202:
> 7stud -- wrote in post #1019196:
>
>> What version are you guys using?   Also what version of ruby, rails and
>> sqlite?
>
> $ rails -v
> Rails 3.1.0.rc8
>
> $ ruby -v
> ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
>
> $ sqlite3 -version
> 3.7.7.1 2011-06-28 17:39:05

Alexey,

I faced with the similar problem in slightly different environment:

(in simply controller)
...
hash = Digest::SHA2.hexdigest
[params[:document][:file].original_filename, current_user.email,
version].join
...
    if current_user.documents.create :path => file.to_s, :hashref =>
hash, :version => version,
...

(logs and dump)
...
INSERT INTO "documents" ("created_at", "description", "hashref",
"mimetype", "path", "updated_at", "user_id", "version") VALUES (?, ?, ?,
?, ?, ?, ?, ?)  [["created_at", Tue, 13 Sep 2011 17:43:16 UTC +00:00],
["description", nil],
> ["hashref", "18da91cbfadb74e43d9ca4231555462d"],
["mimetype", "[text/plain]"], ["path", "y1.txt"], ["updated_at", Tue, 13
Sep 2011 17:43:16 UTC +00:00], ["user_id", 1], ["version", 0]]

sqlite> .dump documents
INSERT INTO "documents"
VALUES(13,1,'y1.txt',
> X'3138646139316362666164623734653433643963613432333135353534363264',
NULL,'[text/plain]','2011-09-13
17:43:16.214665','2011-09-13 17:43:16.214665',0);

So I can't refer to this record using hash value.  But!  If I add just a
little modification to hash string, just a single char other than
[0-9a-f] (say hash += "*"), everything works well:

sqlite> .dump documents
INSERT INTO "documents"
VALUES(14,1,'test-text',
> '6c9034ddb7f1f248e6a215a1d335ff94*',
'tt1','[]','2011-09-13
17:59:25.925458','2011-09-13 17:59:25.925458',0);

I'm using Rails 3.1, Ruby 1.9.2p290 and sqlite 3.7.7.1.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to