Get rid of single-use and slight awkward model scope
Really dont like that raw Arel.sql wrapping that is required.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
module UsersHelper
|
||||
def prepend_current_user_to(users_scope)
|
||||
users_scope.to_a.prepend(Current.user).uniq
|
||||
end
|
||||
end
|
||||
@@ -18,7 +18,6 @@ class User < ApplicationRecord
|
||||
normalizes :email_address, with: ->(value) { value.strip.downcase }
|
||||
|
||||
scope :alphabetically, -> { order("lower(name)") }
|
||||
scope :sorted_with_user_first, ->(user) { order(Arel.sql("users.id != ?, lower(name)", user.id)) }
|
||||
|
||||
def initials
|
||||
name.to_s.scan(/\b\p{L}/).join.upcase
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</p>
|
||||
|
||||
<div class="flex align-center flex-wrap gap-half max-width txt-normal">
|
||||
<%= render partial: "bubbles/watches/watcher", collection: @bubble.watchers.sorted_with_user_first(Current.user) %>
|
||||
<%= render partial: "bubbles/watches/watcher", collection: prepend_current_user_to(@bubble.watchers.alphabetically) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user