NoMethodError (undefined method `gsub' for #<File:0x007faa7258fd80>) when gsub was never used!

I am presented with this error in my code, the line number happens to be -->

Filestore.create(:filename => uploaded_file.original_filename , :fileblob =>, :bunch => @current_bunch )

The code directly uses gsub nowehere, what could be the possible issue?

It probably means you are passing a parameter of the wrong type, so
the underlying code is calling gsub, expecting it to be a string I
imagine, but it is actually a File.

What is a Filestore? You should use the techniques described in the
Rails Guide on Debugging to break in and inspect the data to check
that it is what you expect.


FileStore is my model name and I have a table too.

I used the puts with ‘instance’.class to check the types and they match as well.

I was incorrectly using instance variables which I replaced with session variables. However the problem persists.

Replacing open with read solved this issue. Thanks everyone!