File.open returns integer not File inconsistency
file-io, ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2
Solution
The statement `x = File.open(...) do |f| ...` sets `x` to the result of the do block, not to the returned file (which is closed after the block finishes). So what you are effectively doing is setting `temp_image` to the result of `f.write`, which is the number of bytes written, not the file object.
Problem
``` temp_image = File.open(Rails.root.join("tmp","project_image.png"), 'wb') do |f| f.write(Base64.decode64(image_data)) end puts temp_image puts File.open(Rails.root.join("tmp","project_image.png")) ``` Output: 24018 < File:0x007fddd55c8db0 > I want the first line to to return the file object as well. Why is it returning the integer?