This file contains hidden or 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
class CreditCard | |
include DataMapper::Resource | |
repository(:default) do | |
property :id, Serial | |
property :month, Integer | |
property :year, Integer | |
property :digits, Integer #last 5 digits | |
end | |
This file contains hidden or 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-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 | |
This file contains hidden or 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
# 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 |
This file contains hidden or 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-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> | |
This file contains hidden or 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
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' |
This file contains hidden or 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 | |
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 |
This file contains hidden or 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
## 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 |
This file contains hidden or 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
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 |
This file contains hidden or 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
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 |
This file contains hidden or 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 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) } |