ubuntu(wsl)
Rails 6.0.3
ruby 2.5.1
CarrierWave
Click here for the error
view/user/show.html.slim
 = link_to image_tag(user.image.url), user
Let's examine the contents of the User model once. ↓ Contents of User model
name: "Shota Fujita",
  email: "[email protected]",
  password_digest: [FILTERED],
  admin: false,
  image: nil,
It seems that the cause is that the value of ʻimage is nil`.
Find the user who is nil with rails c etc. and delete it.
Add the following to ʻimage_uploader.rb`.
app/uploaders/image_uploader.rb
  def default_url(*args)
    'default.png'
  end
Put the images in ʻapp / assets / images` and you're done.
-[Rails] basic image_tag and how to set default image
Recommended Posts