This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe '#save' do | |
describe 'with a new resource' do | |
it "should create when the resource is dirty" do | |
Zoo.new(:city => "San Diego").save | |
Zoo.first.name.should == "San Diego" | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'dm-core' | |
class Zoo | |
include DataMapper::Resource | |
property :id, Serial | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merb.logger.info("Compiling routes...") | |
Merb::Router.prepare do |r| | |
# This deferred route allows permalinks to be handled, without a separate rack handler | |
match("/:permalink").defer_to do |request, params| | |
unless (article = Article.find_by_permalink(params[:permalink)).nil? | |
{:controller => "articles", :action => "show", :id => article.id} | |
end | |
end | |
# Admin namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merb::Router.prepare do |r| | |
#Merbauth routes is broken (capture is depricated) | |
slice(:MerbAuth, :path => "", :default_routes => false) | |
# This is the default route for /:controller/:action/:id | |
# This is fine for most cases. If you're heavily using resource-based | |
# routes, you may want to comment/remove this line to prevent | |
# clients from calling your create or destroy actions with a GET | |
default_routes | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As a translation leader, you will maintain a fork of the book that represents | |
the authoritative status of the book in your language. Matt will then periodically | |
pull from your repository (or you can send him a pull request) when it is time to | |
update the master repository. You may then manage permissions to your repository | |
and give write permissions to anybody able to contribute in your language. | |
To set this up, do the following: | |
1. Fork the master repo (this is done via the github web interface). | |
2. Clone your fork of the repository to your local system: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put me in an initializer! | |
module ActionController | |
module Routing | |
class RouteSet | |
attr_accessor :routes | |
def initialize | |
@routes = [] | |
@route_structure = {} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@user = User.new | |
respond_with(@user) do | |
format.xml | |
format.html do | |
if @user.saved? | |
format.html { redirect_to(@user) } | |
else | |
render :action => "new" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# heredocs can continue the code on the same line: | |
class SomeController | |
def render opts | |
p opts | |
end | |
def setup; false; end | |
def action_a | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear_sources | |
bundle_path "vendor/bundler_gems" | |
bin_path "vendor/bin" | |
source "http://gemcutter.org" | |
source "http://gems.github.com" | |
gem "rails", "2.3.4", :only => :bundle | |
gem "clearance" | |
gem "will_paginate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo gem install rack nokogiri mongrel --no-rdoc --no-ri | |
# curl http://gist.github.com/raw/258378/31dc0cc39faf8328cc6b5b5e2fa2a973153f174d/gistfile1.txt > hello_world.rb | |
# ruby hello_world.rb | |
require 'rubygems' | |
require 'rack' | |
require 'nokogiri' | |
require 'open-uri' | |
class HelloWorld |
OlderNewer