Did you know that you can create a single-file Rails application?
You shouldn't unless you are experimenting with something, but regardless, let me show you how it's done.
Let's create a file and call it "app.ru", the "ru" extension means it will be a rackup file. Then we need to use bundler inline to install the dependencies:
Next, we require Rails and configure Active Record to use a sqlite database and we define the database schema and create a model:
Next step is to create an "App" class, and set the necessary configuration. We also set the root route to point to the WelcomeController's index action:
Final step is to add a controller, initialize the app and run it.
Then from a terminal, you can run "rackup app.ru" and you have a single file Rails application.
I run an indie startup providing vulnerability scanning for your Ruby on Rails app.
It is free to use at the moment, and I am grateful for any feedback about it.
If you would like to give it a spin, you can do it here: Vulnerability Scanning for your Ruby on Rails app!
Did you enjoy reading this?Follow me on Twitter or sign up to my newsletter for more content like this!