How to display picture on rails

Hi all,

I want to display the picture(BLOD type in sqlite3 in Ubuntu) I cannot display picture on the screen., i just show some decode stuff. and i try to use the plug in paperclip.. and when i install it on the current project, I cannot run my server in Terminal,

please give me some advice

Thanks

Hi all,

I want to display the picture(BLOD type in sqlite3 in Ubuntu) I cannot display picture on the screen., i just show some decode stuff.

It is no good just saying you cannot display it and you get some 'decode stuff'. Show us the code you have written that you think should display the picture and whatever is shown on screen where the image should be displayed. First have a look at the html being generated (View > Page Source or similar in your browser) and make sure that the html being generated is what you expect. I would expect you to be using image_tag to show the image.

and i try to use the plug in paperclip.. and when i install it on the current project, I cannot run my server in Terminal,

Is this a separate question? If so I would advise just having one question in a post, otherwise the answers to the two questions will get mixed up. Again though it is no good just saying you cannot run the server, otherwise the only reply you will get is that you are doing something wrong. Tell us the error message when you run the server.

Colin

Colin

in view: <%=@patient.image %>

in controller

@user=Picture.all( :joins => :culture, :conditions => (Phrase.joins(:description))).first

and it shows this on the screen,

GIF89a���ý����f�*����zd����:2eZJ�������R�̙����ݼ�iZA:0��ޙ������B���|||����^R����c�������Ͼ�ϫthS�

if i use ==> <%=image_tag(@user.image) %> it will error me “string contains null byte”

give help… thanks

in view: <%=@patient.image %>

That’s just dumping the raw data into the page. Your browser won’t know that the data represents an image unless there is an img tag, whose src attribute points at an action in your app that will send back the data comprising the image. You might also consider embedding the images inline via a data: url

Fred

Here's how I display images with paperclip:   <% if items.picture.url(:medium) =~ /missing.png/ %>     <%= link_to image_tag( items.picture.url,:size => '300x300', :border=> 0), items.picture.url, :target => '_blank' %>   <% else %>     <%= link_to image_tag( items.picture.url(:medium), :border=> 0), items.picture.url, :target => '_blank' %>   <% end %>

Notice the image tag - items.picture.url not the base object.

Hope this helps.