I am trying to display an image stored in my MSSQL database in my Rails
2 application. As a test example I have written a C# application that
displays the image on a form which works. So I know the image in my
database is correct.
However when I try to retrieve the image by the following code it gives
me an rails error:
def show_account_logo
@account = Account.find(params[:id])
send_data @account.account_logo, :type => ‘image/png’, :disposition =>
‘inline’
end
The following error is returned:
NoMethodError (undefined method unpack' for #<Array:0x15b8fc44>): c:/ruby/lib/ruby/1.8/base64.rb:59:in
decode64’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-sqlserver-adapter-1.0.0.9250/lib/active_record/connection_adapters/sqlserver_adapter.rb:134:in
binary_to_string' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/attribute_methods.rb:211:in
account_logo’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/attribute_methods.rb:240:in
send' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.1.2/lib/active_record/attribute_methods.rb:240:in
method_missing’
/app/controllers/manage/user_controller.rb:526:in `show_account_logo’
The following link on the internet is supposed to have the solution,
however that page doens’t exist any longer.
http://blog.mcmoyer.com/2007/9/18/using-ms-sqlserver-with-rails
Any help would be appreciated.