I'm trying to print only the value of a JSON and I'm getting the error no implicit conversion of String into Integer.
Any idea how I can resolve this?
puts test.class
Azure::Armrest::ArmrestCollection
Here is the output of the varaible and I want to print only the quantity value.
puts test
[----] I, [2022-08-23T08:59:20.279357 #550:bc494] INFO -- automation: Method STDOUT: {"id":"/subscriptions/123456/providers/Microsoft.Commerce/UsageAggregates/Daily_BRSDT_20220801_0000","name":"Daily_BRSDT_20220801_0000","type":"Microsoft.Commerce/UsageAggregate","properties":{"subscriptionId":"123456","usageStartTime":"2022-07-31T00:00:00+00:00","usageEndTime":"2022-08-01T00:00:00+00:00","meterName":"Data Transfer Out","meterRegion":"North America","meterCategory":"Bandwidth","meterSubCategory":"Inter-Region","unit":"1 GB","instanceData":"{\"Microsoft.Resources\":{\"resourceUri\":\"/subscriptions/123456/resourceGroups/cloud-shell-storage-centralindia/providers/Microsoft.Compute/virtualMachines/ubuntu975\",\"location\":\"eastus\",\"additionalInfo\":{\"PipelineType\":\"v2\",\"DataTransferDirection\":\"DataTrOut\"}}}","meterId":"dbefcfc1-e3f6-409b-be6d-9cd7b00724a5","infoFields":{},"quantity":9.052455425262451e-07}}
[----] I, [2022-08-23T08:59:20.280435 #550:bc494] INFO -- automation: Method STDOUT: {"id":"/subscriptions/123456/providers/Microsoft.Commerce/UsageAggregates/Daily_BRSDT_20220801_0000","name":"Daily_BRSDT_20220801_0000","type":"Microsoft.Commerce/UsageAggregate","properties":{"subscriptionId":"123456","usageStartTime":"2022-07-31T00:00:00+00:00","usageEndTime":"2022-08-01T00:00:00+00:00","meterName":"Dynamic Public IP","meterCategory":"Virtual Network","meterSubCategory":"IP Addresses","unit":"1 Hour","instanceData":"{\"Microsoft.Resources\":{\"resourceUri\":\"/subscriptions/123456/resourceGroups/cloud-shell-storage-centralindia/providers/Microsoft.Network/publicIPAddresses/Ubuntu975-publicIp\",\"location\":\"eastus\",\"additionalInfo\":{\"IpAddress\":\"20.25.57.9\",\"PlatformType\":\"V2-Agg\"}}}","meterId":"f114cb19-ea64-40b5-bcd7-aee474b62853","infoFields":{},"quantity":1.0}}
puts test["properties"]["quantity"]
[----] E, [2022-08-23T08:59:28.949873 #544:b6620] ERROR -- automation: <AEMethod getcostusage> [no implicit conversion of String into Integer]
/CloudForms_Essentials/Integration/Azure/StateMachines/getCostUsage:79:in `[]'
/CloudForms_Essentials/Integration/Azure/StateMachines/getCostUsage:79:in `<main>'
[----] I, [2022-08-23T08:59:28.974301 #544:ac260] INFO -- automation: <AEMethod [/CloudForms_Essentials/Integration/Azure/StateMachines/getCostUsage]> Ending
If I try JSON.parse(test) then I get this error.
[----] E, [2022-08-23T09:18:39.022825 #553:bcaac] ERROR -- automation: <AEMethod getcostusage> [no implicit conversion of Azure::Armrest::ArmrestCollection into String]
test is an instance of ArmrestCollection, which inherits from Array class (as can be viewed here).
To print the quantity of all elements, you can iterate it and print them each individually:
test.each do |element|
puts element["properties"]["quantity"]
end
Trying to set up image uploading on my website, but whenever I test uploading an image, it fails and I get these errors in the log... I've looked through so many fixes but none seem to work correctly.
If anyone could point me towards a fix or let me know what exactly is going wrong that would be great. Thanks.
2021-04-18T19:33:58.653571+00:00 app[web.1]: [6e2d06ab-891e-4970-8fbe-2e9fb2868eca] ActiveModel::UnknownAttributeError (unknown attribute 'service_name' for ActiveStorage::Blob.):
2021-04-18T19:33:58.653571+00:00 app[web.1]: [6e2d06ab-891e-4970-8fbe-2e9fb2868eca]
2021-04-18T19:33:58.653572+00:00 app[web.1]: [6e2d06ab-891e-4970-8fbe-2e9fb2868eca] app/controllers/gigs_controller.rb:88:in `upload_photo'
2021-04-18T19:33:58.748015+00:00 app[web.1]: I, [2021-04-18T19:33:58.747897 #4] INFO -- : [16714095-28f1-4c97-8e78-407316f869dd] Started GET "/gigs/6/edit?step=4" for [ip address] at 2021-04-18 19:33:58 +0000```
I have a huge rails code many routes and i see the console that says for the route home/index
Processing by HomeController#index as HTML
but i don't even see with binding.pry that the route hit but i get 200OK response in my terminal i see that there are many filters being called but i don't know which filter is being called as there are 100's of modules being include.
Is there a formula that guides us telling which page the action has traversed through which module only in the project but not to the internal rails code like traversing inside the rails gem and all.
I get a very white screen on chrome for localhost:3000/ where there is no layout being loaded. So i need to backtrace to what actions has my route hit and what and all callbacks are involved in performing that action.
Its waste of time with binding.pry putting at lots of places.
I, [2019-11-07T13:41:06.046091 #22077] INFO -- : Started GET "/" for 127.0.0.1 at 2019-11-07 13:41:06 +0530
[DEPRECATION] `strip_attributes!` is deprecated. Please use `strip_attributes` (non-bang method) instead.
[DEPRECATION] `strip_attributes!` is deprecated. Please use `strip_attributes` (non-bang method) instead.
W, [2019-11-07T13:41:07.190395 #22077] WARN -- : Creating scope :track_allowed. Overwriting existing method CustomFieldDefinition.track_allowed.
W, [2019-11-07T13:41:07.190553 #22077] WARN -- : Creating scope :document_allowed. Overwriting existing method CustomFieldDefinition.document_allowed.
W, [2019-11-07T13:41:07.190643 #22077] WARN -- : Creating scope :image_allowed. Overwriting existing method CustomFieldDefinition.image_allowed.
W, [2019-11-07T13:41:07.190724 #22077] WARN -- : Creating scope :video_allowed. Overwriting existing method CustomFieldDefinition.video_allowed.
[DEPRECATION] `strip_attributes!` is deprecated. Please use `strip_attributes` (non-bang method) instead.
[DEPRECATION] `strip_attributes!` is deprecated. Please use `strip_attributes` (non-bang method) instead.
W, [2019-11-07T13:41:07.325206 #22077] WARN -- : Creating scope :by_ids. Overwriting existing method MediaFormat.by_ids.
I, [2019-11-07T13:41:07.334538 #22077] INFO -- : Processing by HomeController#index as HTML
D, [2019-11-07T13:41:07.336651 #22077] DEBUG -- : Track Load (0.6ms) SELECT "tracks".* FROM "tracks" WHERE (tracks.purged_at IS NULL)
I, [2019-11-07T13:41:07.339979 #22077] INFO -- : Completed 200 OK in 5ms (ActiveRecord: 2.3ms | Path: http://localhost:3000/)
If you are assuming that the / (root path) should hit HomeController#index I think you should check your routes.
A specific url always can only hit one action. In this case your log tells us it is processed by the MainController#home method.
Check your routes (in config/routes.rb) and check your root definition.
It should be
root to: 'home#index'
(and also check if there are multiple occurrences)
I spend around 4 - 5 hours on this and now seeking help from you. I am trying to execute a Cucumber feature file via Ruby and getting below error via command prompt.
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansic
on/) to get coloured output on Windows
D, [23-10-2014 09:19:09 #1244] DEBUG -- : --------------------------------------
--
D, [23-10-2014 09:19:09 #1244] DEBUG -- : start time: 2014-10-23 09:19:09 +1100
C:/testapp/features/support/env.rb:56: warning: class variable access from toplevel
Variable is set in env.rb file and feature file and ruby code as below
Given(/^Testing feature"(.*?)" Open the page$/) do |feature_name|
test_url = $url_config["testdata"]["test_poc"]["test_url"]
#browser = $browser_instance
#browser.goto(test_url)
$logger.debug "Opened the page"
puts "Opened the page"
end
Note: When I put the URL directly to the test_url = "http://www.google.com" it's working.
I have log file in Rails 4.
Here is string.
I, [2014-09-30T19:16:23.434591 #6942] INFO -- : Completed 302 Found in 1176ms (ActiveRecord: 4.6ms)
What means number after DATETIME? #6942?
it is process id: PID
Log format: SeverityID, [DateTime #pid] SeverityLabel -- ProgName: message
Log sample: I, [1999-03-03T02:34:24.895701 #19074] INFO -- Main: info.
http://www.ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html#class-Logger-label-Format