Forum: Ruby on Rails How to display an image in my view from a BLOB column ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-07-04 11:16
I have a model  'Picture' with a blob column 'small'  and a string
column 'extension'

in my PictureController , I want to show it in the show view

my show action is quite simple

  def show
    @user = User.find(params[:user_id])
    @picture = @user.picture

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @picture.to_xml }
    end
  end

what should I write in my show.rhtml view to display it ?

 I thought to add  in my show action
   send_data(@picture.small, :filename => @user.id.to_s +'-small.'+
@picture.extension, :type => @picture.extension, :disposition =>
'inline')

and in my view
<img src="<%=  @user.id.to_s +'-small.'+ @picture.extension  %>" />

but it seems to be wrong

thanks for your help
This topic is locked and can not be replied to.