Skip to content

Instantly share code, notes, and snippets.

@dallas
dallas / rails31init.md
Created September 11, 2011 05:22 — forked from docwhat/rails31init.md
Rails 3.1 with Rspec, Factory Girl, Haml, Simple Form, Database Cleaner, Spork, and Guard

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@a2ikm
a2ikm / nested_const.rb
Created September 9, 2011 07:06
Get or set nested constant
#!/usr/bin/ruby
class Object
# copied from http://blog.udzura.jp/2010/03/08/petit-hacking-about-const_get/
def self.nested_const_get(name)
stack = (name.is_a?(Array)) ? name : name.to_s.split("::")
klass = Object
while const = stack.shift
klass = klass.const_get(const)
end
... .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.html)$ file.php?target=$1 [QSA,L]
#敢えてファイルが存在するときで、末尾に.htmlが付くファイルの場合のみリライトさせる
</IfModule>
# A simple app that implements a naive session-based login, to demonstrate the problems with testing sessions in Sinatra.
require 'rubygems'
require 'sinatra/base'
class LoginApp < Sinatra::Base
enable :sessions
get '/' do