Skip to content

Instantly share code, notes, and snippets.

@valk
valk / sandbox.rb
Created June 12, 2013 19:22
How to run Rails server and perform other commands from a Ruby script file.
#!/usr/bin/env ruby
# Put this file in /script/ directory.
require 'rails/commands/server'
Rails::Server.new.tap { |server|
APP_PATH = File.expand_path('../../config/application', __FILE__)
require APP_PATH
Dir.chdir(Rails.application.root)
server.start
@valk
valk / gist:5764490
Created June 12, 2013 11:22
Restore Ubuntu / Linux terminal with preset working directories and tab title names.
#!/bin/sh
gnome-terminal \
--tab -t "guard" --working-directory=$HOME/projects/my_project \
--tab -t "server" --working-directory=$HOME/projects/my_project \
--tab -t "console" --working-directory=$HOME/projects/my_project \
--tab -t "cli" --working-directory=$HOME/projects/my_project \
--tab -t "root" --profile=root
@valk
valk / index.md
Last active December 17, 2015 15:59 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one