Skip to content

Instantly share code, notes, and snippets.

View rhodee's full-sized avatar
💭
hi.

Denis rhodee

💭
hi.
  • Austin, TX
View GitHub Profile
@rhodee
rhodee / _test.rb
Created January 3, 2013 03:26 — forked from jcoglan/_test.rb
$VERBOSE = nil
require File.expand_path('../rooby', __FILE__)
Person = Rooby::Class.new 'Person' do
define :initialize do |name|
@name = name
end
define :name do
@rhodee
rhodee / friendly_urls.markdown
Created November 18, 2012 03:49 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

@rhodee
rhodee / database.yml.example mysql2
Created July 23, 2012 13:45 — forked from erichurst/database.yml.example mysql2
Rails 3 database.yml examples
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
defaults: &defaults
adapter: mysql2 #or mysql