Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'fileutils'
require 'pathname'
require 'addressable/uri'
require 'ruby-github' # TODO: replace ruby-github with something better maintained
require "bundler"
Bundler.setup
require "dm-core"
require "dm-types"
require "dm-migrations"
DataMapper.setup(:default, "mysql://localhost/test")
class User
irb(main):005:0> @seed.inside{User.all("name" => "Taco")}
~ (0.000007) SET sql_auto_is_null = 0
~ (0.000002) SET SESSION sql_mode = 'ANSI,NO_BACKSLASH_ESCAPES,NO_DIR_IN_CREATE,NO_ENGINE_SUBSTITUTION,NO_UNSIGNED_SUBTRACTION,TRADITIONAL'
~ (0.000003) SELECT `id`, `crypted_password`, `salt`, `login`, `email`, `name`, `administrator`, `billing_contact`, `created_at`, `updated_at` FROM `users` WHERE `name` = 'Taco' ORDER BY `id`
=> []
irb(main):006:0> @seed.inside{User.all("name.like" => "Taco")}
ArgumentError: is an invalid instance: NilClass
from /Library/Ruby/Gems/1.8/gems/dm-core-0.10.2/lib/dm-core/query.rb:1170:in `append_condition'
from /Library/Ruby/Gems/1.8/gems/dm-core-0.10.2/lib/dm-core/query.rb:1238:in `append_string_condition'
from /Library/Ruby/Gems/1.8/gems/dm-core-0.10.2/lib/dm-core/query.rb:1166:in `append_condition'
just a place to put code snippets
puts RubyGem.first(:name=>"dm-core").dependencies.map{|d| d.version }.compact.map{|v|v.rubygem.name}.uniq.sort
caelesta:~ knowtheory$ macgem list
*** LOCAL GEMS ***
caelesta:~ knowtheory$ clear
caelesta:~ knowtheory$ macgem install jeweler
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/Gems
require 'pathname'
dir = Pathname(__FILE__).dirname.expand_path + 'wimple'
require dir + 'document'
module Wimple
module Markup
class Strategy
attr_reader :strategy_block, :prerequisites, :key
class Human
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :ownerships
has n, :pets, :through => :ownerships
end
class Ownership
10:13:18 < knowtheory> yeah, i'm a datamapper guy, i haven't kept up with the new AR hotness
10:13:34 < knowtheory> how are people finding AR in Rails3?
10:14:20 < KinkyKamikaze> Awesome
10:14:22 < KinkyKamikaze> I like it
10:14:25 < knowtheory> yeah? :)
10:14:28 < KinkyKamikaze> The queries make sense now, it's never hard to build them
10:14:33 < KinkyKamikaze> and not brittle at al
10:14:40 < knowtheory> neat :)
10:14:44 *** spastorino ~spastorin@r186-48-225-193.dialup.adsl.anteldata.net.uy has joined #railsbridge
10:14:50 < KinkyKamikaze> I like datamapper too, come form Django, the Django ORM syntax is the same as DM
09:23:55 < kevinalford> WOMEN
09:23:56 < kevinalford> ok
09:24:13 < KinkyKamikaze> kevinalford: I am sorry?
09:24:21 *** wmoxam ~wmoxam@206-248-129-20.dsl.teksavvy.com has quit [Ping timeout: 276 seconds]
09:24:41 < kevinalford> do you have ovaries?
09:24:51 < invalidrecord> he bitches like he does ;)\
09:25:03 < KinkyKamikaze> Wow..
09:25:07 < KinkyKamikaze> I am not commenting this >.<
09:25:12 < KinkyKamikaze> anyway gotta go, cya.
09:25:17 < invalidrecord> ok man l8rs
caelesta:dm knowtheory$ rails dm-site -m http://github.com/snusnu/rails-templates/raw/master/dm_rails_master.rb
create
create README
create .gitignore
create Rakefile
create config.ru
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb