Displaying 20 results from an estimated 4000 matches similar to: "loading an image to instance variable of AR"
2010 Dec 05
3
Strange problem with CSV and funny chars
I am using CSV in a rake task (db:seed) on Rails 3.0.3, Ruby 1.9.2 to
read a file with some funny chars in it. Upon breaking in at a point
where the row read using CSV is in variable row, with the string with
the char in row[''price''] I get the following strange results which I
cannot understand.
(rdb:1) row[''price'']
"\xA32.00"
(rdb:1)
2010 Apr 29
2
send_data => invalid byte sequence in US-ASCII
I''m trying to display a generated .png plot via send_data(), but it
results in a server error "invalid byte sequence in US-ASCII" error.
I''m pretty sure this means that I need to specify the encoding
somewhere, but I haven''t been able to figure out where or how to do so.
Some particulars:
I''m running gnuplot through a pipe to generate a plot in .png
2006 Nov 04
0
send_data from disk
Hi, I''m trying to use send_data to stream a file that is stored on my disk
(not as a blob in the database.)
So, this is what I''ve tried:
send_data File.new(filename).read
But, the file doesn''t download. I think send_data expects something other
than a String (which is returned by File.read.) Anyone know how to get this
working?
The reason this is being done is to
2009 Nov 08
2
send_data with jpeg not working
I''m a newbie having trouble using send_data to send a jpeg file to the
browser for display in an html img tag. This is the relevant code
from my controller (photos_controller.rb):
def retrieve
@photo = Photo.find(params[:id])
send_data File.read(@photo.abs_img_path), :type => "image/
jpeg", :disposition => "inline"
end
def download
@photo =
2006 May 09
2
Computing very large exponents
Greetings all.
Does anyone have a clue how to use Ruby to do modular exponentiation
using the binary left-to-right method? I looked through the
documentation and searched the forums and found the String.each_byte
method. However I had no luck finding anything showing how one might
manipulate bits of bytes.
Below is an example of what I am talking about.
The calculation a = b^e mod n (or
2008 Feb 07
6
Buffer flushing
Short question: is there way to tell EM to actually send data after
send_data call?
I''m building a file transferring app. I send Mashal.dump''ed metadata
first, and then - the file contents (chunked). I found a silly bug:
receive_data() gets marshalled metadata and the first chunk of the
file in a single variable.
Like that:
c1.send_data("meta")
2005 Mar 08
3
Extracting images from a DB
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I would like to extract an image BLOB from my database and display it
alongside some other information on my ''edit'' page. I read the
information here
http://wiki.rubyonrails.com/rails/show/HowtoUploadFiles
and that was really helpful.
However, it still isn''t clear to me how I would get access to the image
in my views if
2008 Jan 06
5
Having very odd problems with UDP.
I am using eventmachine 0.8.1 on windows XP and am having very odd problems.
This snippet of code gives the error that follows it.
class EchoServer
def receive_data data
puts data
send_data ">>>you sent: #{data}"
if data =~ /quit/i
puts "quitting"
close_connection
EventMachine::stop_event_loop
end
end
end
2006 May 22
2
Problem with send_data and csv file produced
hi, i did a search and couldn''t find wat''s the problem with my code...
it seems everything is the same and the result is what i expected but i
am not sure where went wrong....
using send_data function to send the csv file to the client, the file
sending is successfully but when i opened the csv file, something is
wrong...
every statement got a "......" inverted
2008 Jan 03
1
Mongrel stops to loading the page in browser
Hi all,
I have a problem with mongrel-1.1.2 running with Apache Apache/2.0.61
and MySQL 5.0.45 on FreeBSD 6.1.
I''m developing my application with InstantRails that uses Mongrel and
everything is working great. I have about 30 shops in a table. I also
store the logo images (png files) in the table for each shop. Under
Windows/InstantRails everything is working correct.
When i however
2006 Jul 07
3
quick send_data question...
Hi,
I am using send_data to allow users to download files from the database
but ran into a small problem, it seems that files upload fine but when
they download only 64kb of the file is sent.
I''m using the basic rails code from the Agile book:
#upload code in my sheet model
def file=(document_field)
self.filename = base_part_of(document_field.original_filename)
2006 May 17
0
send_data not working properly with link_remote_to
I''m reading an image in an link_to_remote call,and then using send_data
i send the read image as :type => "image/png" :disposition =>
"inline"...but when the div tag gets updated i see only ascii characters
.....but if i do the same operation using normal call(link_to) i see it
functioning normal ....could someone explain .
my view:
<%=
2006 Jan 04
4
How to open a pdf file in new window
Hi all
I made a pdf file in ruby and to display it used the method send_data
like
#
send_data pdf.render, :filename => "Hello.pdf",:type =>
"application/pdf"
#
Now I want to open it in another window or as a popup. How can I achieve
it?
Thanks to all.
Sainaba.
--
Posted via http://www.ruby-forum.com/.
2012 Mar 13
1
send_data always sends xml file?
I''m trying to use send_data to send a simple text file.
Every reference I can find says I can supply a MIME type with the
":type" option and that will determine the kind of file I get on the
machine that downloads the file I''m sending. Instead I ALWAYS get an
XML file.
here''s the code snippet:
File.open(@temp_download_file_path, ''r'') do
2010 Dec 22
0
image_tag and send_data
i''m storing images in database.
i have this action in controller:
def image
begin
item = StoredItem.find(:first, :conditions => {:id =>
params[:id]})
rescue
return
end
return if item.nil?
if item.image_binary.nil?
render :nothing => true
else
send_data(item.image_binary, :type => item.image_datatype,
:disposition =>
2007 Jul 24
0
send_data and ie
Has anyone else had trouble using send_data with internet explorer. As
usual things were working fine in firefox and safari until I tested in
IE :).
With the following code I''m seeing an image show up in firefox but the
"X" indicating no image found in IE. Any ideas?
@image_data = Image.find(:all, :conditions=>{:url =>
"http://reddit.com"})
@image =
2006 Jan 09
6
Rendering dynamic Gruff image (send_data)
Dears,
Got a controller witch do a send_data for displaying a chart.
like :
send_data(g.to_blob, :filename => "any.png", :type => ''image/png'',
:disposition=> ''inline'')
I actually do a
<img src="http://myhost:3000/stats/make_graph" />
Is there any way more clean to do that ? At minima don''t hardcode the
beginning
2010 Nov 03
2
send_file but not send_data?
So this is the original code I used, and it worked
send_file ''vendor/sprites/not-found.png'', {:filename =>
"sprite-not-found.png", :type => "image/png", :disposition => "inline"}
Now I switched it to this (going to be adding imageMagick)
send_data File.read(''vendor/sprites/not-found.png''), {:filename =>
2008 Jul 14
0
How to Send Itext Generated PDF to Browser?
I am still attempting to figure out how to send an Itext generated pdf
Document to the browser.
I am looking at the following blog posting where someone is using jruby
and iText to create a pdf file and then sending it to the browser :
http://codersifu.blogspot.com/2007/06/howto-generate-pdf-files-in-ruby-on.html
Unlike the above example I am using only ruby / on rails.
I would like to do
2006 Sep 12
2
Generate JS from RoR - strange delay with send_data
Hi!
I need to generate some JS from Ruby. This is no AJAX related stuff so
RJS templates are not help to me. Also I want to not mix JS with HTML,
so putting JS in .rhtml templates is no go for me.
Currently I made some action in controller, prepared JS code and I''m
sending it via send_data as ''text/javascript''. In .rhtml templates I use
<script> tag with src