i use ruby on rails on my backend and mysql2 as database, and as you can guess from my nickname i'm newbie in rails.
{
"last_viewed_categorie" : "shirt",
"last_name" : "herose",
"login_screen_apperaed" : 1,
"item_added_to_cart" : 5,
"first_name" : "george"
}
this is the json format that i'm currently receiving to my database. What i want is this something like that
jsonColumns //array that contains keys of json
jsonColumns.each do |jsonColumn|
unless @existingColumnNames.include?(jsonColumn)
"Alter table mutable add_column #{jsonColumn}"
I can't seem to find any way to make something like this to run,
Is it even possible?
if it's not possible can you offer a similar one?
Thank you
mysql2would be your database driver, and MySQL is your database. Also worth noting, variable names in Ruby are, by tradition, expressed likejson_columns.