Pump your fist and nod your head and maybe scream: “I DID IT!” Then get to work, you’ve only just begun. That’s it! You just built a new Rails app! It’s an API-only application, and it’s all set for a PostgreSQL database. 7) celebrate for ten seconds, then get to work 5) cd into your new Rails folder cd super-awesome-api 6) create a Git repo for your Rails appĭon’t forget to keep track of your Rails app’s development on GitHub! Now’s a good time to create a new Git repo for your Rails app. Here is an example of a Ruby on Rails application built with the Ruby 2.2 image using the PostgreSQL 9.4 image as a database backend. Note 2: I plan on creating another directory later, called super-awesome-client, where I’ll be creating my Super Awesome App’s React frontend. New RHSCL-based Docker images that are now in beta let you easily build your own application containers even without writing any Dockerfiles. In other words: rails new project-name-here -api -database=postgresql First, add a Dockerfile at the root level of your Rails application. Note 1: you can give your Rails project any name you want. In this guide I’ll explain how to dockerize an existing Rails application and use Docker Compose to run the application with a Postgres database. This will create a Rails project directory named super-awesome-api. rails -v gem update rails 4) create new rails API with a PostgreSQL database rails new super-awesome-api -api -database=postgresql Rails changes frequently each application is known to work and serves as your personal reference implementation. Hundreds of developers use the apps, report problems as they arise, and propose solutions. The RailsApps project provides example applications that developers use as starter apps. This seems like a good best practice, so why not. This is an article from the RailsApps project. 1) create folder mkdir super-awesome-app 2) cd into that folder cd super-awesome-app 3) make sure your Rails version is up to dateįor the hell of it, make sure your Rails version is up to date before creating a new Rails app. I like using PostgreSQL for my database because Heroku likes PostgreSQL, and I like making my Rails app an API-only application because I’ll be creating a separate React frontend for my app, so I don’t need a bunch of empty Views folders in my Rails app, since I won’t be using them.įor the purpose of this tutorial, let’s imagine we’re creating a super awesome app, and we’re going to call it Super Awesome App. So I’m leaving these notes here for myself, and anyone else who finds this helpful. First we need to create a postgres role for the rails application, name the role as your app. Creating a New Rails API with a PostgreSQL DatabaseĮvery time I create a new Rails API with a PostgreSQL database, I find myself googling “create a new Rails API with a PostgreSQL database”. So far you should have everything install to set up the project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |