Tuesday, November 26, 2013

rspec

This tests everything:

bundle exec rspec spec/

This tests the specification stored in static_pages_spec.rb:

bundle exec rspec spec/requests/static_pages_spec.rb

Github


Initial repository setup:
Log into Github and setup a new repository.





Leave blank the box in front of "Initialize this repository with a README"

Populate the repository with your local copy:
$ git remote add origin https://github.com/<username>/MyNewRepository.git 

$ git push -u origin master


Update Github with current files:
$ git push


Git basics

Typical process:

Make changes
git add .
git commit -a -m "What I am changing"
git push

Add the files in your new Rails project to Git and then commit the results:
$ git add .
$ git commit -m "Initialize repository"

Identify changed files:
$ git status

View commit messages:
$ git log


Start a new branch:
$ git checkout -b my-new-branch

List branches:
$ git branch

Commit all the new changes since last commit:
$ git commit -a -m "Describe what these changes do"

Merge my new branch back into master:
$ git checkout master 

$ git merge my-new-branch

Delete the branch that is no longer needed
$ git branch -d my-new-branch



Undo screwups:
This rolls back to the last commit in the current branch.

The -f flag forces Git to overwrite changes since the last commit.
$ git checkout -f 


Undo a major screwup: 
This rolls back to a different branch and deletes the messed up branch
$ git checkout -b my-new-branch 
$ [do some stuff to really mess up the branch] 
$ git add . 
$ git commit -a -m "Major screw up" 
$ git checkout master 
$ git branch -D my-new-branch


[Notes taken from Ruby on Rails Tutorial]

Git initial config

One-time system setup:
$ git config --global user.name "Your Name" 

$ git config --global user.email your.email@example.com
$ git config --global core.editor "gvim -f"

First-time repository setup:
Change into the directory that houses your repository (project).  Then:

$ git init

Edit .gitignore to tell Git to ignore certain files:

----- 

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

# Ignore other unneeded files.
database.yml
doc/
*.swp
*~
.project
.DS_Store
.idea
.secret

-----


[Notes taken from Ruby on Rails Tutorial]

Change dark blue comments in vim to a brighter color

Can't see comments and other dark blue text in a vim window? Try this:

:set background=dark


If you like it, you can make it permanent by adding this line to your ~/.vimrc file:


set background=dark

 
 

Monday, November 18, 2013

How to install Ruby 2.0.0p247 and Rails 4.0 on Amazon Ubuntu instance

How I installed Rails

First install Ruby:

I tried to avoid using sudo.  I don't remember exactly when I used sudo in the steps below.  When you see "sudo", that's a post-install guess that I probably used it there.

sudo apt-get -y update
sudo apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
tar -xvzf ruby-2.0.0-p247.tar.gz
cd ruby-2.0.0-p247/
./configure --prefix=/usr/local
make
sudo make install

----------------------

I installed Rails by following this web page:

https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm

Noting the relevant bits here in case that page goes down/changes:

sudo apt-get update
sudo apt-get upgrades
sudo apt-get install curl

This installs RVM.  RVM is a Ruby version manager.  I want this in case I need to use different versions of Ruby (maybe later).
\curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements

I don't know if this next part might be redundant.  I wonder if I should have installed RVM first, before installing Ruby.

rvm install ruby
rvm use ruby --default

This installs rubygems.  Not sure what gems are.  Wikipdedia says:

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.

rvm rubygems current

This installs rails:
gem install rails



----------------------

Currently trying to follow this introductory Rails guide:

http://guides.rubyonrails.org/getting_started.html

The guide assumes I have SQLite3 installed.  I think this installed sqlite3:

sudo apt-get install sqlite3 libsqlite3-dev
sudo gem install sqlite3-ruby

I don't recall if I had to configure stuff for sqlite3.  There may have been on-screen instructions I had to follow.