Hello I am working on a shopify embedded app with ruby on rails and I must save some config parameters given by the user or me.
I couldn’t find any solution other than using heroku postgres database.
I looked everywhere for a code to insert or select data from the heroku database but I was unsuccessful in the Doc they literally gave one line of code in Ruby section.
https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-ruby
in the Gemfile add :
gem 'pg'
I have no idea how to execute any Query on the database with ruby in my controller.
EDIT :
I did all the configuration for the pg gem all I need to know is some example of code on how to use it
Use case example:
- The app home have Input and Save button.
- User 1 Enter data in input and Click save.
- User 1 close the app.
- User 1 returns to the app.
- User 1 finds the data he wrote in the input.
Please help.
2
Answers
Solved It with the help of reddit community.
All I had to do is adding this in my controller:
Query Example
It would be more usual to save configuration info as heroku config vars, rather than in Postgres.
heroku config
will list the current vars andheroku config:set VAR_NAME=var_value
will set vars. This is not Ruby code – it is a part of heroku setup.If you truly want to write Ruby on Rails code to modify the database, you need to learn ActiveRecord