Change how ruby executes commands

This commit is contained in:
spengreb 2019-10-08 22:20:34 +02:00
parent c893e37a65
commit 2981d737a9
2 changed files with 37 additions and 1 deletions

View file

@ -5,7 +5,7 @@ class VouchersController < ApplicationController
# GET /vouchers
def index
@vouchers = Voucher.all
whitelist = system 'mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} "whitelist list" | sed "s/There are*.*whitelisted players: //g"'.gsub("\n", "").split(", ")
whitelist = %x[mcrcon -c -H mine.vereto.net -p #{ENV["MC_RCON_PASS"]} 'whitelist list' | sed 's/There are*.*whitelisted players: //g'].gsub("\n", "").split(", ")
render json: { :vouchers => @vouchers, :whitelist => whitelist }.to_json
end

View file

@ -2338,3 +2338,39 @@ Processing by VouchersController#index as */*
Completed 200 OK in 111ms (Views: 0.1ms | ActiveRecord: 1.1ms | Allocations: 6058)
Started GET "/vouchers" for ::1 at 2019-10-08 22:17:10 +0200
 (0.5ms) SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
 (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC
Processing by VouchersController#index as */*
Completed 500 Internal Server Error in 8ms (ActiveRecord: 0.0ms | Allocations: 768)
NoMethodError (undefined method `gsub' for true:TrueClass):
app/controllers/vouchers_controller.rb:8:in `index'
Started GET "/vouchers" for ::1 at 2019-10-08 22:17:16 +0200
Processing by VouchersController#index as */*
Completed 500 Internal Server Error in 10ms (ActiveRecord: 0.0ms | Allocations: 125)
NoMethodError (undefined method `gsub' for true:TrueClass):
app/controllers/vouchers_controller.rb:8:in `index'
Started GET "/vouchers" for ::1 at 2019-10-08 22:18:54 +0200
Processing by VouchersController#index as */*
Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms | Allocations: 719)
NoMethodError (undefined method `gsub' for true:TrueClass):
app/controllers/vouchers_controller.rb:9:in `index'
Started GET "/vouchers" for ::1 at 2019-10-08 22:19:17 +0200
Processing by VouchersController#index as */*
Voucher Load (0.3ms) SELECT `vouchers`.* FROM `vouchers`
↳ app/controllers/vouchers_controller.rb:10:in `index'
Completed 200 OK in 122ms (Views: 0.2ms | ActiveRecord: 1.4ms | Allocations: 6017)