Class: Thredded::AutocompleteUsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/thredded/autocomplete_users_controller.rb

Constant Summary collapse

MAX_RESULTS =
20

Instance Method Summary collapse

Methods included from UrlsHelper

#delete_post_path, #edit_post_path, #edit_preferences_path, #edit_preferences_url, #mark_unread_path, #permalink_path, #post_path, #post_url, #quote_post_path, #search_path, #send_private_message_path, #topic_path, #topic_url, #unread_topics_path, #user_path

Instance Method Details

#indexObject



7
8
9
10
11
12
13
# File 'app/controllers/thredded/autocomplete_users_controller.rb', line 7

def index
  authorize_creating Thredded::PrivateTopicForm.new(user: thredded_current_user).private_topic
  users = params.key?(:q) ? users_by_prefix : users_by_ids
  render json: {
    results: users.map { |user| user_to_autocomplete_result(user) }
  }
end