Giter VIP home page Giter VIP logo

rails-commands-cheatsheet's Introduction

rails-commands-cheatsheet

Rails commands

# Create a new app
rails new myapp
# Generate a complete scaffold (migration, model, controller, views)
rails g scaffold Object attribute:datatype

# Eg. Create a scaffold for a book with a title, author and summary
rails g scaffold Book title:string author:string summary:text
# Generate a controller and view/s
rails g controller controller_name action


# Eg. Create a home index page/home controller with index action
rails g controller home index
# Generate a data model with corresponding migration (a data model/database table)
rails g model Object attribute:datatype
# Add an attribute to a data model/database table
rails g migration AddAttributeToObject attribute:datatype
# Start the server
rails s

# Stop the server
Cntrl + C

Rake commands

# create database tables from migration file
rake db:migrate
# seed the database with data in db/seeds.rb file
rake db:seed
# rollback the last migration
rake db:rollback
# check your app’s routes
rake routes

Git commands

# Initialise a git repository for your app
git init
# Add all files to your repository
git add --all
# Commit all changes to your repository
git commit -am 'message'
# Check the state of your git repository
git status
# Check your repository remote links
git remote -v
# Push the master branch of your repository to a remote named origin
git push origin master
# Create a new branch and checkout the new branch in one command
git checkout -b newbranch

Heroku commands

# Create a new app/repository on Heroku
heroku create appname
# Migration
heroku run rake db:migrate
# Check Heroku logs
heroku logs

rails-commands-cheatsheet's People

Watchers

 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.