1

I'm trying to display a users profile image, along with their username in an autocomplete dropdown.

The autocomplete functionality works fine, I'm just having trouble displaying the actual image in the dropdown. I get the image URL instead of the image.

I'm using carrierwave for image uploading and jQuery-UI for autocomplete.

users_controller.rb:

def index
  @users = User.order(:username).where("username like ?", "%#{params[:term]}%")
  render json: @users.map{ |user| "#{user.username} - #{user.user_photo}"}
end

The form:

<% if policy(@list).add_collaborators? %>
  <h3>Add Collaborator</h3>
  <%= form_for [@list, @collaboration] do |f| %>
    <%= label_tag "Enter collaborator username" %>
    <%= text_field_tag :username, nil, data: {users_source: users_path} %>
    <%= f.submit "Add collaborator" %>
  <% end %>
<% end %>

Image of what I'm getting:

This is what I'm getting

I feel like there's a pretty easy solution for this, what am I missing?

Thanks for any help anyone can send my way!

EDIT: Please let me know if anyone needs any more info about my project.

0