The ACES Train Sucks, Takes Longer Than Driving

The ACES Train from NY to AC takes longer than driving. Its hard to convince someone of the convenience and pollution impacts of taking a train when it takes longer than driving. COM’ON ‘MERICA your trains suck.

Weihenstephaner Hefewiess Bier

Weihenstephaner Hefewiess Bier

Two Paragraphs of Lorem Ipsum

Don’t you hate that lipsum.com makes you choose 5 paragraphs and hit “Generate Lorem Ipsum” before giving you Lorem Ipsum? TAKE FOREVER. Now you can reference loremipsum.erictarn.com instead for all your ipsum needs.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque luctus elementum nisl, ullamcorper mollis nisi facilisis at. Vivamus ullamcorper enim at enim porta in porta diam pulvinar. Mauris non tempus ante. Pellentesque elementum dapibus dui venenatis gravida. Nullam at mi velit, eget consequat nisi. Suspendisse nec tortor eros. Aenean pulvinar neque et felis vehicula ac tincidunt lectus iaculis. Curabitur semper condimentum porta. Integer venenatis laoreet tellus non faucibus. Maecenas condimentum diam eget sapien eleifend tristique.

Pellentesque ac fringilla justo. Sed dictum turpis sed lorem mollis varius. Vivamus mi tortor, varius a accumsan nec, scelerisque ac nulla. Mauris pretium ultricies orci sollicitudin condimentum. Ut a lacus diam, vitae tempor turpis. Nunc eros nisi, euismod vitae aliquet a, ultrices ut neque. Morbi et nisi neque. Sed mattis tincidunt odio ac placerat. Donec fermentum malesuada bibendum. Aenean consequat posuere lacinia. Nullam ut purus justo, vel posuere risus. Nullam nec rhoncus est. Nam ac ipsum purus, a dapibus lectus. Praesent lorem metus, molestie ac auctor vitae, tincidunt eu lorem. Proin id dapibus ligula. Vestibulum elementum laoreet erat et gravida. Suspendisse ac egestas diam.
Chicken over rice from the cart on 23rd and 6th, the SW one.

Chicken over rice from the cart on 23rd and 6th, the SW one.

Refactoring your config/database.yml file

A less annoying database.yml file when you use the same database for all three environments

defaults: &defaults
    adapter: mysql
    encoding: utf8
    reconnect: false
    pool: 5
    username: admin
    password: welcome1

development:
    database: friendster_dev
    <<: *defaults

test:
    database: friendster_test
    <<: *defaults

production:
    database: friendster
    <<: *defaults

How come its always so hard to find documentation for the database.yml file?

Rice three ways - moro from havana central, yellow rice from havana central, fried rice from a korean deli.

Rice three ways - moro from havana central, yellow rice from havana central, fried rice from a korean deli.

Fixtures for Ruby on Rails Testing

/test/fixtures/users.yml

<%
  def auto_increment
    @id ||= 0; @id += 1
  end
%>
tommy:
  id: <%= auto_increment %>
  email: tommy@thedocks.com
  created_at: <%= 6.months.ago.to_s(:db) %>
gina:
  id: <%= auto_increment %>
  email: gina@jerseydiner.com
  created_at: <%= 1.minute.ago.to_s(:db) %>

/test/unit/user_test.rb

fixtures :users

def test_can_access_tommy_fixture
  assert(users(:tommy) != nil)
end

Import your fixture records into the current environment: rake db:fixtures:load

Default Ruby on Rails Scaffold Code

Sometimes when things get crazy, you need to reference the default stuff.

class ArticlesController < ApplicationController
  # GET /articles
  # GET /articles.xml
  def index
    @articles = Article.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @articles }
    end
  end

  # GET /articles/1
  # GET /articles/1.xml
  def show
    @article = Article.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @article }
      format.json { render :json => @article }
    end
  end

  # GET /articles/new
  # GET /articles/new.xml
  def new
    @article = Article.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @article }
    end
  end

  # GET /articles/1/edit
  def edit
    @article = Article.find(params[:id])
  end

  # POST /articles
  # POST /articles.xml
  def create
    @article = Article.new(params[:article])

    respond_to do |format|
      if @article.save
        flash[:notice] = 'Article was successfully created.'
        format.html { redirect_to(@article) }
        format.xml  { render :xml => @article, :status => :created, :location => @article }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @article.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /articles/1
  # PUT /articles/1.xml
  def update
    @article = Article.find(params[:id])

    respond_to do |format|
      if @article.update_attributes(params[:article])
        flash[:notice] = 'Article was successfully updated.'
        format.html { redirect_to(@article) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @article.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /articles/1
  # DELETE /articles/1.xml
  def destroy
    @article = Article.find(params[:id])
    @article.destroy

    respond_to do |format|
      format.html { redirect_to(articles_url) }
      format.xml  { head :ok }
    end
  end
end
3 4 5 6 7