Git Product home page Git Product logo

locomotive's Introduction

Locomotive

A guide to setting up a rails app, from zero to deployed, with some common components

A few notes before we begin

I won’t be telling you when to check in changes to Git. Figure it out yourself. I recommend doing it often.

The basics

Create an empty GitHub repository: http://github.com/new.

Clone it:

$ git clone [email protected]:ihmccreery/locomotive.git

Initialize a Rails project:

$ cd locomotive/
$ rails new .

Change the README to Markdown:

$ git rm README.rdoc
$ touch README.md

At this point, all things should be good in the world:

$ rails server

Databases

Let's make some databases.

First off, let's get something straight. Use PostgreSQL. Just do it. If you don't already have PostgreSQL running, and you're on OS X, I recommend Postgres.app.

In your Gemfile:

# Use PostgreSQL as the database for Active Record
gem 'pg'

Your config/database.yml should look like this:

development:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: locomotive_dev
  pool: 5

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: postgresql
  encoding: unicode
  host: localhost
  database: locomotive_test
  pool: 5

Make some databases:

$ createdb locomotive_dev
$ createdb locomotive_test

Run the initial migration to create a schema:

$ rake db:migrate

That's it for now!

Testing

Let's use RSpec. First thing, get rid of Test::Unit:

$ git rm -r test/

And install rspec-rails, Machinist, and Capybara:

# Use RSpec for testing
group :development, :test do
  gem 'rspec-rails'
  gem 'machinist'
  gem 'capybara'
end

And follow these guides:

Templating

Haml, of course: gem 'haml-rails'. No other setup required. Hurrah. You can use Html2Haml to convert any old files, (I'm looking at you, layouts/application.html.erb!).

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.