Skip to content

Instantly share code, notes, and snippets.

# what breaks
<% blogs = @story.user.blogs %>
# with:
Cannot find the child_model Blogadmin for User
# the relationship in User
# doesn't work
def self.treeify_comments(clist, pid = 0)
chash = Hash.new # comments grouped by parent_id
comhash = Hash.new # comments in a hash, w/ comment id as key
comments = Array.new # for the ordered comments
depth_tree = Hash.new # comment depth
clist.collect { |x| comhash[x.id] = x }
# ?
clist.collect do |c|
chash[c.parent_id] ||= Array.new
class StoryController < ApplicationController
#require 'utility'
def index
@story = Story.get(params[:id])
#@comments = repository(:default).adapter.query('SELECT comments.id, story_id, user_id, parent_id, time, sid, cid, pid, subject, recrate, trollrate, raters, commentip, comment, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id)
#@comments = Comment.find_by_sql(['SELECT comments.id, subject, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id])
# experiment...
clist = repository(:default).adapter.query('SELECT comments.id, story_id, user_id, parent_id, time, sid, cid, pid, subject, recrate, trollrate, raters, commentip, comment, nickname from comments left join users on comments.user_id = users.id where story_id = ?', @story.id)
chash = Hash.new
class MessageController < ApplicationController
def index
@messagee = User.by_name(params[:nick])
end
def newpmthr
if request.post?
pmthr = PMThread.new
unless (pmthr)
raise "Something's wrong"
begin
require "memcached"
rescue LoadError
require "memcache"
rescue LoadError
puts "You need the memcache or the memcached gem to use the Memcache moneta store"
exit
end
module Moneta
begin
require "memcached"
rescue LoadError
puts "You need the memcached (the libmemcached client, not the other one) gem to use the Memcached moneta store"
exit
end
# uses the memcached gem properly, and traps the weirdass exception a get on an undefined key throws. May be worth changing
# further to allow the extra flags memcached lets you use, like marshal => true|false or the various memcached flags