How to use database triggers in Rails

This page summarizes the projects mentioned and recommended in the original post on dev.to

Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
Get early access to Scout Monitoring's NEW Ruby logging feature [beta] by signing up now. Start for free and enable logs to get better insights into your Rails apps.
www.scoutapm.com
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • Ruby on Rails

    Ruby on Rails

    I don't think it is superfluous to clarify to folks who might not be familiar with Rails how migrations work. In Rails, we create classes for migrations in the db/migrate folder that inherit from ActiveRecord::Migration[:rails_version]. This is a good example of metaprogramming in Ruby. Instead of directly inheriting from the ActiveRecord::Migration class, ActiveRecord::Migration has redefined the [] (square brackets) method to dynamically create a class with features available for the specified Rails version and return it, so we can inherit from it. This allows us to use migrations created in previous versions of Rails even after updating Rails. The newly created class typically has two methods, up and down, which apply and revert the changes to the database, respectively. Alternatively, it might have a single change method if the changes can be automatically reversed by Rails. The name of the file containing the class starts with a 14-digit timestamp, and Rails maintains a table with one column containing these timestamps for executed migrations. This ensures that migrations are run only once and in the order they were created when you type rails db:migrate. This system ensures smooth database schema changes and consistency across different environments. It's important to mention that the SQL code we will write in the next section will be compiled and executed by the database engine, so if we need to make changes, we need to revert the migration, change the code, and execute it again. You can read more about migrations here: Rails Migrations Guide.

  • Scout Monitoring

    Performance metrics and, now, Logs Management Monitoring with Scout Monitoring. Get early access to Scout Monitoring's NEW Ruby logging feature [beta] by signing up now. Start for free and enable logs to get better insights into your Rails apps.

    Scout Monitoring logo
  • portfolio

    My portfolio app (by Gavrilajava)

    Now, everything should be working smoothly. You can find a working example here, and the source code is available in this GitHub Repository. If you have any suggestions or feedback, please feel free to leave a comment.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Ruby on Rails pluck method

    1 project | dev.to | 17 Jul 2024
  • New Rails 7.2: Added Rate Limiting

    1 project | dev.to | 3 Jul 2024
  • Level Up Your Coding Skills for Free!

    2 projects | dev.to | 9 Jun 2024
  • How Our Expertise Helped Curb Real Estate Communication Chaos

    2 projects | dev.to | 5 Jun 2024
  • Building an Ruby on Rails MVP.

    1 project | dev.to | 24 May 2024

Did you konow that Ruby is
the 12th most popular programming language
based on number of metions?