lib/locomotive/liquid/drops/content_types.rb
# Modify the attributes of the with_scope tag so that
# they can be resolved by MongoDB.
#
Modify the attributes of the with_scope tag so that
they can be resolved by MongoDB.
Modify the attributes of the with_scope tag so that they can be resolved by MongoDB .
def modify_with_scope
          @context['with_scope'].dup.each do |key, value|
            field = @content_type.find_entries_custom_field(key.to_s)
            next if field.nil?
            case field.type.to_sym
            when :belongs_to
              self.modify_with_scope_key(key, "#{key.to_s}_id", self.object_to_id(field, value))
            when :many_to_many
              self.modify_with_scope_key(key, "#{key.to_s.singularize}_ids", self.object_to_id(field, value))
            when :select
              option = field.select_options.detect { |option| [option.name, option._id.to_s].include?(value) }
              self.modify_with_scope_key(key, "#{key.to_s}_id", option.try(:_id))
            end
          end
        end
def modify_with_scope @context [ 'with_scope' ] . dup . each do | key , value | field = @content_type . find_entries_custom_field ( key . to_s ) next if field . nil? case field . type . to_sym when :belongs_to self . modify_with_scope_key ( key , "#{key.to_s}_id" , self . object_to_id ( field , value ) ) when :many_to_many self . modify_with_scope_key ( key , "#{key.to_s.singularize}_ids" , self . object_to_id ( field , value ) ) when :select option = field . select_options . detect { | option | [ option . name , option . _id . to_s ] . include? ( value ) } self . modify_with_scope_key ( key , "#{key.to_s}_id" , option . try ( :_id ) ) end end end
Modify the attributes of the with_scope tag so that
they can be resolved by MongoDB.
Modify the attributes of the with_scope tag so that they can be resolved by MongoDB .