macOS 10.15.5

The image is a picked-up image, but such a "mark that the image is not displayed" appears. However, I want to display the image set as the initial image normally.

The structure of the folder is like this.

∟ images
∟ default_icon.jpg

BD column name isimageis.


def create
    @user = User.new (
      name: params [: name],
      email: params [: email],
      image: "default_icon.jpg"
    if @ user.save
      redirect_to ("/ users/# {@ user.id}")
    else else
      render ("users/new")


<p><% = @ user.name%></p>
<p><% = @ user.email%></p>
<% = link_to ("edit", "/ users/# {@ user.id}/edit")%>

The mark that is not displayed appears.

What I tried

I changed the extension of the image to png and changed the image itself.
After that, I thought that it was necessary to set CSS, so I tried setting it, but there was no change.
I also tried restarting the server.
I also tried changing the browser.

  • Answer # 1

    I think it's easier to use a helper method called image_tag

    <% = image_tag @ user.image.url%>

    By the way, you need to use uploader such as CarrierWave to save the image.

Related articles