1
0
Fork 0
forked from OpenNeo/impress

Rename ClosetList.public -> publicly_visible

This removes a conflict with a new Rails method `.public` on the model!
This commit is contained in:
Matchu 2023-07-29 11:37:46 -07:00 committed by Matchu
parent 97bf520674
commit 7edfda6d19
2 changed files with 4 additions and 2 deletions

View file

@ -86,7 +86,7 @@ class ClosetHangersController < ApplicationController
end end
else else
# Otherwise, default to public lists # Otherwise, default to public lists
visible_closet_lists = closet_lists.public visible_closet_lists = closet_lists.publicly_visible
end end
@closet_lists_by_owned = closet_lists.group_by(&:hangers_owned) @closet_lists_by_owned = closet_lists.group_by(&:hangers_owned)
@visible_closet_lists_by_owned = find_closet_lists_by_owned(visible_closet_lists) @visible_closet_lists_by_owned = find_closet_lists_by_owned(visible_closet_lists)

View file

@ -8,7 +8,9 @@ class ClosetList < ActiveRecord::Base
validates :hangers_owned, :inclusion => {:in => [true, false], :message => "can't be blank"} validates :hangers_owned, :inclusion => {:in => [true, false], :message => "can't be blank"}
scope :alphabetical, -> { order(:name) } scope :alphabetical, -> { order(:name) }
scope :public, -> { where(arel_table[:visibility].gteq(ClosetVisibility[:public].id)) } scope :publicly_visible, -> {
where(arel_table[:visibility].gteq(ClosetVisibility[:public].id))
}
scope :visible_to, ->(user) { scope :visible_to, ->(user) {
condition = arel_table[:visibility].gteq(ClosetVisibility[:public].id) condition = arel_table[:visibility].gteq(ClosetVisibility[:public].id)
condition = condition.or(arel_table[:user_id].eq(user.id)) if user condition = condition.or(arel_table[:user_id].eq(user.id)) if user