Hi I would like how can I execute a query like (Postgres sql) INSERT INTO oids ("filename", "picture") VALUES('logo.png',lo_import(file));
in rails..Why I am asking this is I have a table oids having fields
id | integer | not null default nextval('oids_id_seq'::regclass) filename | character varying(255) | default NULL::character varying picture | oid
I am trying to save an image file directly to picture field..My view file is
<%= form_tag ({:action => "createoid"}, {:enctype => 'multipart/form-data'}) %> <label for="picture">Picture for OID</label> <%= file_field_tag "logo" %> <%= submit_tag "Save" %> <%= end_form_tag %> and controller is
def createoid @pi = Oid.new @pi.filename=params[:logo].original_filename.gsub(/[^a-zA-Z0-9.]/, '_') @pi.picture=params[:logo].read @pi.save end
I am getting error ArgumentError: Invalid Ruby/cstring: INSERT INTO oids ("filename", "picture") VALUES('logo.png', '�PNG��� Then some nonreadable chlues like above And if the datatype above where bytea instead of oid no problem
Please help Thanks in advance Sijo