Giter Club home page Giter Club logo

railswalkthrough's Introduction

RailsWalkThrough

Walking through building a Rails app from scratch.

This walkthrough runs through setting up a new Rails app, using Docker and docker-compose, applying bootstrap themes, setting up deployment to Heroku, and then building a timecard app.

Setting up the dependencies.

We're going to be using Docker and docker-compose to run our development environment. This makes it much easier to make sure that what runs on my machine also runs on yours. And that we can manage our development, test and production environments.

So, install Docker on your development machine first, and then setup docker compose.

You will also need curl or wget to get started.

Building our development environment

It's worth reading up on Docker and docker-compose separately - but for the purpose of this exercise, I will use the Evil Martians to Docker work.

We'll start by creating a directory for our work:

mkdir RailsWalkthrough
`cd RailsWalkthrough

As the files we need are embedded in another Github repository, and we don't intend to contribute back to them, we'll simply get them via cURL:

curl https://raw.githubusercontent.com/evilmartians/terraforming-rails/master/examples/dockerdev/docker-compose.yml -o docker-compose.yml
mkdir .dockerdev
cd .dockerdev/
curl https://raw.githubusercontent.com/evilmartians/terraforming-rails/master/examples/dockerdev/.dockerdev/Dockerfile -o Dockerfile
curl https://raw.githubusercontent.com/evilmartians/terraforming-rails/master/examples/dockerdev/.dockerdev/Aptfile -o Aptfile
curl https://raw.githubusercontent.com/evilmartians/terraforming-rails/master/examples/dockerdev/.dockerdev/.bashrc -o .bashrc
curl https://raw.githubusercontent.com/evilmartians/terraforming-rails/master/examples/dockerdev/.dockerdev/.psqlrc -o .psqlrc

OK, so now we have everything we need to build the Docker images for development. Next, we may as well open our folder in the code editor of choice - I'm going to be using VS Code - and edit the docker-compose.yml file. Look for the line image: example-dev:1.0.0 and edit it to a name you're happy with - I'm going to use rails-walkthrough:0.0.1.

Once you've done that, you can start the runner:

docker-compose run --rm runner

This will build the Docker images, and open a shell onto the main machine. Next, install rails:

gem install rails

Now we have a functioning rails environment, so we'll tell rails to build a new application:

rails new . -d postgresql

This should create a new rails application in the current directory; if you have your IDE opened on the directory, you'll see lots of new files and folders turn up.

Next, we need to change the database configuration to point at the postgres container in our docker environment. Open config/database.yml, and add

host: postgres
user: postgres

to the development and test entries.

You can now set up the rails databases:

rails db:create
rails db:migrate

At this point, you've installed Rails, created an empty project, and initialized the database.

Final step is to open a new terminal window, and run

docker-compose up rails

This will start the Rails webserver; you can visit the homepage to verify.

You can check this all out at todo

railswalkthrough's People

Contributors

nevware avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.