Hi I am new to Ruby and Json. Need help with this command being used in
Ruby, for parsing Json files.
I get the following error,
no implicit conversion of Symbol into String (TypeError)
./lib/pages/admin/summary_pg.rb:13:in `format’
This is how its being used,
class summarypage
def get_language_text(language, type, text)
if language.downcase == "french"
format :json
fr_file = File.read("/config/data/api/admin/labels_FR.json")
fr_file_parsed = parse_file(fr_file)
@text_fr = fr_file_parsed[type][text]
end
@text_fr
end
def parse_file(language_file)
JSON.parse(language_file)
end
end
require ‘json’ is already included in another environment config file.
if I don’t use the format :json, I get the following error,
undefined method `[]’ for nil:NilClass (NoMethodError)
Appreciate the help. Thanks, Joel