If you are on Rails version 7.0 and up, refer to the sqlcommenter-ruby README instead
This is a demo Rails API application to demonstrate sqlcommenter_rails integration.
Install Ruby v2.6.3 if you don't already have it installed.
This demo requires functionality provided by an open PR to marginalia. Install the PR by cloning modulitos's fork of marginalia one directory above this demo. Starting from the root directory of this demo:
git clone https://github.com/modulitos/marginalia.git ../marginalia
git -C ../marginalia checkout formattingInstall dependencies and prepare the database:
bin/setupStart the server:
bin/rails sRun this command in a separate terminal to monitor SQL queries:
tail -f log/development.log | grep 'Post 'The demo app has 2 endpoints: GET /posts and POST /posts.
curl localhost:3000/postsPost Load (0.1ms) SELECT "posts".* FROM "posts" /*action='index',application='SqlcommenterRailsDemo',controller='posts',db_driver='ActiveRecord::ConnectionAdapters::SQLite3Adapter',framework='rails_v6.0.0.rc1',route='/posts',traceparent='00-828f28f7fb3df3dd07ee6478b2016b2a-a52cad0a8d1425ab-01'*/
curl -X POST localhost:3000/posts -d 'title=my-post'Post Create (0.2ms) INSERT INTO "posts" ("title", "created_at", "updated_at") VALUES (?, ?, ?) /*action='create',application='SqlcommenterRailsDemo',controller='posts',db_driver='ActiveRecord::ConnectionAdapters::SQLite3Adapter',framework='rails_v6.0.0.rc1',route='/posts',traceparent='00-ff19308b1f17fedc5864e929bed1f44e-6ddace73a9debf63-01'*/ [["title", "my-post"], ["created_at", "2019-06-08 15:47:59.089692"], ["updated_at", "2019-06-08 15:47:59.089692"]]