To set this up you will need to download this gist. Change into the directory this gist is in then;
rails new your_app_name --database=postgresql -m ./template.rb
export OP_ACCOUNT=yunojuno.1password.com | |
# Create .env.local if it does not exist | |
if [ ! -f .env.local ] | |
then | |
echo "Creating .env.local" | |
cat <<EOF > .env.local | |
# Place secret env variables from 1Password and custom overrides here | |
# | |
# Any variables here will override ones set in .env.native.dist |
Steps to deploy a Node.js app to DigitalOcean using PM2, NGINX as a reverse proxy and an SSL from LetsEncrypt
If you use the referal link below, you get $10 free (1 or 2 months) https://m.do.co/c/5424d440c63a
I will be using the root user, but would suggest creating a new user
rails new <project_name> -d postgresql --skip-turbolinks --skip-spring -T
-d postgresql
sets up the project to use PostgreSQL--skip-turbolinks
& --skip-spring
creates a project that does not use turbolinks or spring-T
skips the creation of the test directory and use of Test::Unit
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)In this article, I'll walk through a basic Rails (3.2.x) setup for creating a nested resource for two models. Nested resources work well when you want to build out URL structure between two related models, and still maintain a RESTful convention. This code assumes you are running RVM to manage Ruby/Gem versions, and Git for version control.
$ mkdir family # create rvm gemset
$ echo "rvm use --create ruby-1.9.2@family" > family/.rvmrc
$ cd family # install rails
$ gem install rails # create new rails project
$ rails new . # version control
# Helpers | |
def git_update(message) | |
git :add => ".", :commit => "-m '#{message}'" | |
end | |
def git_remove(file) | |
git :rm => file | |
end |
require 'yaml' | |
snippets = ::YAML.load <<-'TEXT' | |
- name: ActiveRecord | |
type: Database / ORM | |
pre_bundle: | |
post_bundle: | |
- name: RSpec | |
type: Unit Test Framework |