Joined December 2014
·

Ratnakar

Kakinada
·
·

I am getting issues with gridfs file system when try to retrieve files from gridfs, I could able to store files(text,pdf) using carrierwave mongoid gridfs and unable to get the data from the mongodb , Can anyone please help me

I uploaded sample text file into gridfs , it stored the file content in database please look at the following record where you can see the actual record from database

email id:="" 547f17f37261740ea9000000,="" from:="" "mail@gmail.com",="" to:="" "mail@gmail.com",="" cc:="" nil,="" bcc:="" nil,="" subject:="" "testmail",="" body:="" "h1.="" give="" redcloth="" a="" try!="" a="" simple="" paragraph="" with="" a="" line="" break="" ,="" someemphasis_and="" a="" \"link\":http:="" redcloth.org",="" attachment1:="" bson::binary:0xe129374="" @data="this is a simple file a couple of lines long\nsecond line\nthird line" ,="" @type=":generic", attachment2: nil, attachment3: nil>

see the field attachment1 it show you the gridfs content and @data stores my actual file content , upto this all is fine , but when I try to get the data from this record I am unable to get it , I tried like the following

@email.attachment1.read ==> shows me nil value

@email.attachment1.file.read => also shows me nil value

also tried @email.instancevariableget(:@data) ==> not worked

How to fix this , please help me .

I am getting the following error undefined method `database' for Mongoid:Module

Achievements
1 Karma
0 Total ProTip Views