A small project showcasing a cool thing you can do with ActiveRecord - creating versioned records in a Rails application without using a gem.
You'll first need an environment that can run Rails (like Unix), or a good Docker image to use for Windows. Second, you'll need Postgres installed locally.
- Clone the project locally
- Once cloned, navigate to the project, and use the
.env.exampleto create a.envfile. This will be used for connecting to the DB locally. - Make sure Ruby and Rails is installed locally. (A version manager like rbenv might also be required if multiple Rails projects are on your machine)
- Run
bundle install
- Before continuing, make sure you have Postgres installed locally, and can access it. This could be through
psql, or a desktop application like PgAdmin or DBeaver. - Create a database locally, you could name it
versionhistory, or whatever suits your fancy. - You could also create a database on a service like Supabase and connect to it locally, it would probably just take a few more steps.
- Find the connection details of your local postgres database. You'll need the
HOST,DATABASE,USERNAME, andPASSWORD.PORTshould default to 5432. - Once connected, you should be able to run your rails commands and start your server!
- With Postgres connected, you should be able to run
rails db:setupto create your tables, load the schema, and run the seeds file that createsCustomersandCustomerVersions. - You may or may not need to run
rake assets:precompileandrake assets:clean. - Start the project up with
rails s