0

This seems like it should be a very simple problem but I've been trying to fix it for ages and getting nowhere. I have a basic Rails app with a model for blog_posts for which images can be uploaded and displayed. On the show.html.erb page one image can be displayed along with data, the image like this:

<%= image_tag @blog_post.image_url if @blog_post.image? %><br><br>

and on the index.html.erb page I have a loop for each image and other data:

<%= image_tag(p.image_url(:thumb), :class => 'list_image') if p.image? %>

In order to center the images I used the following css:

img { display: block; margin-left: auto; margin-right: auto }

But I found that this only centered the images in the show page, but not in the index. I've tried every way to center the image in the index, but nothing seems to work. I can't understand why the image is not recognised by the img selector, and I've also tried affecting the thumb image by putting in various div ids and div classes, but nothing has worked.

This may seem a bit vague but I can't figure out what the problem might be, so any pointers would be very much appreciated :-)

EDIT

The uploader render the images to the following:

  process resize_to_fit: [500, 400]

  version :thumb do
    process resize_to_fit: [300, 200]
  end
Robert
  • 109
  • 3
  • 13

0 Answers0