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
| justin@justin-sl:~/merb/blog$ ls gems/gems/ | |
| abstract-1.0.0 mailfactory-1.4.0 merb-slices-1.0 | |
| addressable-1.0.4 merb-1.0 mime-types-1.15 | |
| data_objects-0.9.6 merb-action-args-1.0 nokogiri-1.0.4 | |
| diff-lcs-1.1.2 merb-assets-1.0 ParseTree-3.0.2 | |
| dm-aggregates-0.9.6 merb-auth-1.0 rack-0.4.0 | |
| dm-core-0.9.6 merb-auth-core-1.0 rake-0.8.3 | |
| dm-migrations-0.9.6 merb-auth-more-1.0 randexp-0.1.4 | |
| dm-sweatshop-0.9.6 merb-auth-slice-password-1.0 rspec-1.1.11 | |
| dm-timestamps-0.9.6 merb-cache-1.0 ruby2ruby-1.2.1 |
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(day, month, year, title) | |
| @post = Post.first(:conditions => ['day = ? AND month = ? AND year = ? AND title LIKE ?', day, month, year, "#{title}%"]) | |
| raise NotFound unless @post | |
| @comments = @post.comments | |
| display @post | |
| 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
| def show(day, month, year, title) | |
| @post = Post.first(:conditions => ['day = ? AND month = ? AND year = ? AND title LIKE ?', day, month, year, "#{title}%"]) | |
| raise NotFound unless @post | |
| @comments = @post.comments | |
| display @post | |
| 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
| def create(comment) | |
| @comment = Comment.new(comment) | |
| if @comment.save | |
| @post = Comment.get(comment[:post_id]) | |
| #eager_cache(:create, [Posts, :show], :store => :action_store) { build_request(build_url(:post, @post)) } | |
| eager_cache([Posts, :show], :store => :action_store) { build_request(build_url(:post, @post)) } | |
| partial "comments/comment", :comment => @comment | |
| else | |
| return "There was an error adding your comment" | |
| 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
| Comment#create | |
| def create(comment) | |
| @comment = Comment.new(comment) | |
| if @comment.save | |
| eager_cache([Posts, :show], :store => :action_store) { build_request(build_url(:post, Post.get(@comment.post_id).to_param)) } | |
| partial 'comments/comment', :comment => @comment | |
| else | |
| return "Error saving comment" | |
| end | |
| 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
| Comment#create | |
| def create(comment) | |
| @comment = Comment.new(comment) | |
| if @comment.save | |
| eager_cache([Posts, :show], :store => :action_store) { build_request(build_url(:post, @comment.post.to_param)) } | |
| partial 'comments/comment', :comment => @comment | |
| else | |
| return "Error saving comment" | |
| end | |
| 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
| def create | |
| ... | |
| ## Using @comment.post and @comment.post.id both error out | |
| eager_cache([Posts, :show], :store => :action_store) { self.class.build_request(url(:post, @comment.post)) } | |
| eager_cache([Posts, :show], :store => :action_store) { self.class.build_request(url(:post, @comment.post.id)) } | |
| ... | |
| end | |
| .... Enter comment into SQL .... |
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
| identify(Post => :id) do | |
| with(:controller => 'posts') do | |
| match("/posts/:id").to(:action => "show").name(:post) | |
| end | |
| 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
| 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)) } |
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::CacheRequest:0xb71318e0 @params={}, @route_params={}, @path="/posts/13", @body=nil, @env={"SERVER_NAME"=>"localhost", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.0.1) Gecko/20060214 Camino/1.0", "HTTP_ACCEPT_ENCODING"=>"gzip,deflate", "PATH_INFO"=>"/", "HTTP_HOST"=>"localhost", "HTTP_ACCEPT_LANGUAGE"=>"en,ja;q=0.9,fr;q=0.9,de;q=0.8,es;q=0.7,it;q=0.7,nl;q=0.6,sv;q=0.5,nb;q=0.5,da;q=0.4,fi;q=0.3,pt;q=0.3,zh-Hans;q=0.2,zh-Hant;q=0.1,ko;q=0.1", "HTTP_CACHE_CONTROL"=>"max-age=0", "SERVER_PROTOCOL"=>"HTTP/1.1", "SCRIPT_NAME"=>"/", "HTTP_KEEP_ALIVE"=>"300", "SERVER_SOFTWARE"=>"Mongrel 1.1", "REMOTE_ADDR"=>"127.0.0.1", "HTTP_REFERER"=>"http://localhost/", "HTTP_VERSION"=>"HTTP/1.1", "HTTP_ACCEPT_CHARSET"=>"ISO-8859-1,utf-8;q=0.7,*;q=0.7", "REQUEST_URI"=>"/", "SERVER_PORT"=>"80", "GATEWAY_INTERFACE"=>"CGI/1.2", "HTTP_ACCEPT"=>"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "REQUEST_METHOD"=>"GET", "HTTP_CONNECTI |