app/controllers/users_controller.rb
# NOTE - this is slightly silly, but the JS plugin we're using really does want all usernames in one call.
this is slightly silly, but the JS plugin we're using really does want all usernames in one call.
this is slightly silly but the JS plugin we ' re using really does want all usernames in one call .
def usernames
    usernames = Rails.cache.fetch('users/usernames', expires_in: 55.minutes) do
      User.all(select: 'username', conditions: 'active = 1').map {|u| u.username }
    end
    render text: usernames.to_json
  end
def usernames usernames = Rails . cache . fetch ( 'users/usernames' , expires_in : 55 . minutes ) do User . all ( select : 'username' , conditions : 'active = 1' ) . map { | u | u . username } end render text : usernames . to_json end
NOTE - this is slightly silly, but the JS plugin we're using really does want all usernames in one call.
NOTE - this is slightly silly but the JS plugin we ' re using really does want all usernames in one call .