Skip to content

Instantly share code, notes, and snippets.

View ravinggenius's full-sized avatar
🤔
likely thinking

Thomas Ingram ravinggenius

🤔
likely thinking
View GitHub Profile
include 'dm-is-list'
class Node
include DataMapper::Resource
property :id, Serial
# other properties...
has n, :parts
end
require 'rubygems'
require 'datamapper'
require 'merb_datamapper'
require 'pp'
require 'app/models/book'
require 'app/models/chapter'
require 'app/models/verse'
merb_root = File.expand_path(File.dirname(__FILE__) / '../')
# @reference http://ruby-metaprogramming.rubylearning.com/html/Dog_Step2.html
class Dog
PHRASES = {
:dance => 'is dancing',
:poo => 'is a smelly doggy!',
:laugh => 'finds this hilarious!'
}
def initialize name
/
This is dynamically generated. node_extensions and templates are located in
the lib/ directory of a Rails application. I don't want the styles that apply
to specific node_extensions to be allowed to "bleed". I know I can use mixins
that get around the problem, but the the styles have to be written just so
for everything to work. You can find the application at
http://github.com/ravinggenius/scratch_pad
Maybe a second boolean parameter (on @import) could be used to override the
current behavior?
#
# Generated by Chef
#
# Based on the Ubuntu apache2.conf
ServerRoot "/etc/apache2"
#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
  • A Filter is a Ruby module with a :process method that accepts text (like MarkDown) and filters it in some way. This is for a CMS. Filters do not get stored in the database.
  • A FilterGroup is (as it likely sounds) a list of Filters to apply to some piece of content. FilterGroups do get stored in the database.
  • Implemented FilterArray as suggested by http://groups.google.com/group/mongomapper/browse_thread/thread/4132688f57f41d17

MongoMapper does not include HABTM relationships. This is my attempt to add them.

<!DOCTYPE html>
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>compass-primary-plugin</title>
<meta content='application/xhtml+xml; charset=utf-8' http-equiv='Content-Type'>
<link href="./test.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<p>header</p>

I have a Rails 3 application; we can consider it a blog system. All content is stored in Nodes. I am using a specifically tailored route to allow Nodes to have clean URLs.

= form_for [:admin, @node] do                        # => generated URL is /admin/nodes or /admin/nodes/4d1a44571d41c821eb000006
= link_to 'all nodes', nodes_path                    # => generated URL is /
= link_to @node.title, node_path(@node.to_path)      # => generated URL is /about or /about/people or /4d1a44571d41c821eb000006
= link_to 'all nodes (admin view)', admin_nodes_path # => generated URL is /admin/nodes
= link_to 'add', new_admin_node_path                 # => generated URL is /admin/nodes/new
= link_to 'edit', edit_admin_node(@node)             # => generated URL is /admin/nodes/4d1a44571d41c821eb000006/edit
= link_to 'delete', [:admin, @node], :confirm => 'Are you sure?', :method => :delete

=> generated URL is /admin/nodes/4d1a44571d41c8

class Idea
include MongoMapper::Document
key :brilliance, String, :default => "Dark Matter Sucks!"
many :ratings
belongs_to :user
key :user_id, ObjectId
def to_s
text = "#{user.name} had this IDEA: #{brilliance}\n\tRATINGS:\n"
ratings.each do |r|