Last active
February 2, 2018 13:44
-
-
Save celine-m-s/9f06f0174d98f0c39765e197f7698cd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check ruby version && rbenv | |
rbenv local | |
# Check last available version of Ruby | |
rbenv install --list | |
# Create app | |
rails _5.1.4_ new appname --database=postgresql | |
# Add pg gem to Gemfile | |
# Add a new role for this app | |
su - postgres | |
# Then create a new user - role for PG | |
create role myapp with createdb login password 'password1'; | |
# Install gems | |
bundle install | |
# Setup DB | |
rake db:setup | |
# Migration | |
rake db:migrate | |
# Rails 5.0 and above | |
rails db:migrate | |
# Go back | |
rails db:rollback | |
# Load seed data | |
rake db:seed | |
# Look for TODO, FIXME or OPTIMIZE in project | |
rails notes | |
# List of available tasks | |
rails -T | |
# Show existing routes | |
rake routes | |
# Scaffolding | |
rails generate scaffold name attribute:type | |
rails g scaffols name attr:type | |
# New controller | |
rails g controller ControllerName actionname | |
# New model | |
rails g model | |
# Destroy model or whatever was made using `generate` | |
rails destroy | |
rails destroy model ModelName | |
# Start server port 3000 by default | |
rails server | |
rails s | |
# localhost:3000 | |
# Console | |
rails c | |
rails console | |
# Specify an environment: | |
rails c staging | |
# Do it without changing any data | |
rails c --sandbox | |
# DB Console: postgres, MySQL, SQLite | |
rails dbconsole | |
# ERB | |
# <%= %> <%= @product.price %> | |
# <% %> <% if user.admin? %><% end %> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment