Skip to content

Instantly share code, notes, and snippets.

class CreditCard
include DataMapper::Resource
repository(:default) do
property :id, Serial
property :month, Integer
property :year, Integer
property :digits, Integer #last 5 digits
end
merb-cache was rewritten with a few goals in mind:
# make it modulular
# define a public API
# do the heavy lifting on key generation
# 100% thread-safe
# work with multiple caching layers through the same API
# keep it hackable
h2. Stores
# or, we can specify eager caching in the action itself
def index(page = 1)
unless page == 1
eager_cache :index do |controller|
controller.params[:page] = page + 1
end
end
display Acticle.paginate(:page => page)
end
merb-cache was rewritten with a few goals in mind:
<ol>
<li>make it modulular</li>
<li>define a public <span class="caps">API</span></li>
<li>do the heavy lifting on key generation</li>
<li>100% thread-safe</li>
<li>work with multiple caching layers through the same <span class="caps">API</span></li>
<li>keep it hackable</li>
</ol>
Fri Aug 15 15:25:39 -0500 2008: Read error: #<NoMethodError: undefined method `each' for nil:NilClass>
/opt/local/lib/ruby/gems/1.8/gems/merb-core-0.9.5/lib/merb-core/rack/handler/mongrel.rb:85:in `process'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
Merb::Router.prepare do
match("/hello") do
match("world").to(:controller => "worlds", :action => "hello") # matches /helloworld
match("there").to(:controller => "theres", :action => "hello") # matches /hellothere
end
default_routes
end
## index.html.haml
[email protected] do |user|
-fetch_partial :short, :object => user # generated key should be "users/_short.html--object=#{user.to_param}"
## admins.html.haml
-fetch_fragment :count => User.admins.count do # key should be "path__to__admins__html__haml-1--count=#{User.admins.count}"
%ul
class Pais
include DataMapper::Resource
# Configuración de las relaciones
has n, :bancos
# Propiedades principales
property :id, Serial
property :nombre, String, :length => (1..50), :nullable => false
property :nombre_corto, String, :length => (1..20), :nullable => false
@benburkert
benburkert / restart.sh
Created October 29, 2008 04:53 — forked from ivey/restart.sh
declare -a pids
i=0
for pid in log/merb.*.pid ; do
if [ $pid == "log/merb.main.pid" ]; then
echo "Killing master process"
kill -9 `cat $pid`
else
pids[$i]=`cat $pid`
fi
@benburkert
benburkert / gist:24314
Created November 12, 2008 23:46 — forked from nitsujw/gist:24313
def show(id)
@post = Post.get(id)
raise NotFound unless @post
display @post
end
def create(comment)
@comment = Comment.new(comment)
if @comment.save
eager_cache([Posts, :show], :store => :action_store) { self.class.build_request(url(:post, @comment.post), :id => @comment.post.id) }