in view I have this
<div>
<% @readers.each do |reader| %>
<% user_profile_url = user_url(reader.user.username) %>
<div>
<%= link_to user_profile_url do %>
<%= reader.user.username %>
<% end %>
<span>[<%= reader.created_at.to_date %>]</span>
</div>
<% end %>
</div>
in the books_controller i have this
def readers_list
@book = Book.find(params[:id])
@readers = @book.downloads.order(created_at: :desc)
end
I have this problem: If an user download twince a book, in this list I see the username twince. So, I know, I have to add uniq
I tried to add it at the end of the @readers, but it didn't work. How (and where) to add it?!
I also tried to make this @readers = @book.downloads.where(user_id: params[:user_id]).order(created_at: :desc), but it didn't work.