Reputation: 11
I am a beginner at Ruby on Rails and Database stuff and I am having a hard time researching how to display image from PostgreSQL and Sqlite3 database to my website using Ruby on Rails, or in Ruby on Rails.
And my problem is "how to display images from database to my website using Rails", just that.
I started with <%= @real_estate.image %>
in my show.html.erb
and then what displays to my website is nothing useful like
#<ActionDispatch::Http::UploadedFile:0x000000000d4fb548>
Upvotes: 0
Views: 622
Reputation: 530
Try something like this:
<%= image_tag @real_estate.image, :alt => 'product_image' %>
My recommendation is to strongly use some cloud storage(like s3 AWS) instead of being inside the database. In the database, save only the url and name of the image.
The fog gem can link your database information with s3 and bring a signed image url.
Upvotes: 1