Hey so I'm having some trouble with CarrierWave & MiniMagick this morning uploaded avatar images are not displaying correctly as you can see highlighted in this screenshot I've dug around the html and controllers and can't find what's wrong so I'll post all that here and see if a second set of eyes might be able to find the issue.
Here is AvatarUploader < CarrierWave::Uploader::Base:
All of these params are copied from my lessons at bloc:
# Process files as they are uploaded:
# process :scale => [200, 300]
process :resize_to_fill => [200, 300]
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :tiny do
process resize_to_fill: [20, 20]
end
version :small do
process resize_to_fill: [30, 30]
end
version :profile do
process resize_to_fill: [45, 45]
end
Here is a snippet from application.html.erb
Note: I am also using devise
<% if current_user %>
<%= image_tag(current_user.avatar.tiny.url) if current_user.avatar? %> Hello <%= link_to (current_user.name || current_user.email), edit_user_registration_path %>!
<%= link_to "Sign Out", destroy_user_session_path, method: :delete %>
<% else %>
<%= link_to "Sign In", new_user_session_path %> or <%= link_to "Sign Up", new_user_registration_path %>
<% end %>
And lastly here is my Users controller:
class UsersController < ApplicationController
before_action :authenticate_user!
def update
if current_user.update_attributes(user_params)
flash[:notice] = "User information updated"
redirect_to edit_user_registration_path
else
flash[:error] = "Invalid user information"
redirect_to edit_user_registration_path
end
end
private
def user_params
params.require(:user).permit(:name, :avatar)
end
end
If you need to see more files, ask and I'll add them.
image_tag current_user.avatar.url(:tiny)
? – Kiloreux