Skip to content

Instantly share code, notes, and snippets.

# comment.rb
class Comment
include DataMapper::Resource
property :id, Integer, :serial => true
property :story_id, Integer
property :user_id, Integer
property :parent_id, Integer
property :time, DateTime
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property.rb:450:in `lazy_load'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property.rb:390:in `get'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `get'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/relationship.rb:74:in `map'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `map'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/property_set.rb:82:in `get'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/relationship.rb:178:in `attach_parent'
/usr/lib/ruby/gems/1.8/gems/dm-core-0.9.11/lib/dm-core/associations/many_to_one.rb:55:in `replace'
# works
# friends, followers
has n, :friended_users
has n, :friends, :through => :friended_users, :class_name => "User", :child_key => [:user_id], :mutable => true
has n, :followers, :through => :friended_users, :class_name => "User", :remote_name => :user, :child_key => [:friend_id], :mutable => true
# does not work
has n, :block_users
has n, :you_blockeds, :through => :block_users, :class_name => "User", :child_key => [:user_id], :mutable => true
has n, :blocked_yous, :through => :block_users, :class_name => "User", :child_key => [:blocked_id], :mutable => true
# since you're curiuos....
# inside the story view
<div id="comments">
<ul class="cm i0">
<% @n = 0 %>
<% @od = 0 %>
<% while @n < @comments.length do %>
<%= render :partial => 'comment/comment', :locals => { :comments => @comments, :depth_tree => @depth_tree } %>
<% end %>
# experiments with logging!
# Logging hook.
before :save, :story_log
# hmm?
before :save!, :story_log
# Logging goodies
def story_log
# the part of the story controller that does the saving and such
def edit
@story = Story.get(params[:id])
@poll = @story.poll[0]
#@blogs = @story.user.blogadmins.map { |b| b.blog }
@blogs = @story.user.allowed_blogs
@taglist = params[:tags] || @story.tags.map { |t| t.tag }.join(", ")
if request.post?
if (params[:commit] == "Preview")
Backtrace:
# File Line Location
0 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 270 in `rescue in require_frameworks'
1 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 266 in `require_frameworks'
2 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 131 in `process'
3 /home/jeremy/dk4-exper/vendor/rails/railties/lib/initializer.rb 110 in `run'
4 /home/jeremy/dk4-exper/config/environment.rb 9 in `'
5 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 267 in `require'
6 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 267 in `preload_application'
7 /usr/local/lib/ruby/gems/1.9.1/gems/passenger-2.2.2/lib/phusion_passenger/railz/application_spawner.rb 227 in `block in initialize_server'
sub url_story {
my $req = shift;
my @path = @_; #shift;
my $p = {};
my $len = scalar @path;
if ($len == 5){
if ($path[$#path] =~ /^-/){
$p->{id} = $path[3];
/* This should be a highly unusual circumstance,
* but apparently there's known issues with
* IE & 'deflate' - as in, IE claims that it can
* handle deflate, but doesn't actually handle
* it correctly. If we have content encoded with
* deflate and our user agent appears to be IE,
* it's probably safest to decompress it and
* let mod_deflate deal with it properly. This
* is along the lines of tossing it over the
* fence and letting Arby's deal with it. */
@ctdk
ctdk / gist:1123201
Created August 3, 2011 17:20
dk4 default recipe
#
# Cookbook Name:: dk4
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
include_recipe "apache2"