Skip to content

Instantly share code, notes, and snippets.

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
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
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
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
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
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
eager_cache(:create, [Post, :show], :store => :action_store)
merb : worker (port 4000) ~ Worker Thread Crashed with Exception:
Unknown property 'eager_dispatch' - (ArgumentError)
/home/justin/merb/blog/gems/gems/dm-core-0.9.6/lib/dm-core/model.rb:452:in `method_missing'
/home/justin/merb/blog/gems/gems/merb-cache-1.0/lib/merb-cache/merb_ext/controller.rb:123:in `_eager_cache_create_to_post__show_after'
/home/justin/merb/blog/gems/gems/merb-core-1.0/lib/merb-core/dispatch/worker.rb:50:in `call'
/home/justin/merb/blog/gems/gems/merb-core-1.0/lib/merb-core/dispatch/worker.rb:50:in `process_queue'
/home/justin/merb/blog/gems/gems/merb-core-1.0/lib/merb-core/dispatch/worker.rb:32:in `initialize'
/home/justin/merb/blog/gems/gems/merb-core-1.0/lib/merb-core/dispatch/worker.rb:31:in `loop'
Show.html.haml
= fetch_partial "posts/post", :post => @post, :updated_at => (@post.updated_at rescue nil)
show action
def show(id)
@post = Post.get(id)
raise NotFound unless @post
display @post
end
Show.html.haml
= fetch_partial "posts/post", :post => @post, :updated_at => (@post.updated_at rescue nil)
show action
def show(id)
@post = Post.get(id)
raise NotFound unless @post
display @post
end
require 'rubygems'
require 'merb-core'
Merb::Config.setup(:merb_root => ".",
:environment => ENV['RACK_ENV'])
Merb.environment = Merb::Config[:environment]
Merb.root = Merb::Config[:merb_root]
Merb::BootLoader.run
run Merb::Rack::Application.new