This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-sqlite-adapter' | |
require 'data_mapper' | |
class Test | |
include DataMapper::Resource | |
property :id, Serial | |
property :title, String, :length => 255 | |
property :description, String, :length => 255 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra/base' | |
require 'sinatra/settings' | |
class YourApp < Sinatra::Base | |
register(Sinatra::Settings) | |
enable :show_settings # turn it on | |
enable :inline_templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts `ruby -v` | |
require 'rubygems' | |
require 'active_support' | |
require 'dm-core' | |
require 'dm-sqlite-adapter' | |
require 'data_mapper' | |
require 'dm-is-list' | |
require 'dm-is-tree' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ENV['HOME'] =~ /^\/home\//) ## DREAMHOST | |
ENV['GEM_HOME'] = "#{ENV['HOME']}/.gems" | |
ENV['GEM_PATH'] = "#{ENV['HOME']}/.gems:" | |
require 'rubygems' | |
Gem.clear_paths | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PROBLEM SYNOPSIS | |
# | |
# Updating the has n :faqs association key :faq_category_id inside a before block in the parent modeL | |
# DOES NOT WORK | |
# | |
# It does however work outside of the before block. | |
# | |
# | |
%w( rubygems dm-core dm-validations dm-timestamps dm-types dm-is-list dm-is-tree ).each { |lib| require lib } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ Using DataMapper::VERSION=[0.10.2] | |
~ begin bootstraps #====================# | |
~ (0.000033) SELECT sqlite_version(*) | |
~ (0.000049) DROP TABLE IF EXISTS "faq_categories" | |
~ (0.000014) DROP TABLE IF EXISTS "faqs" | |
~ (0.000009) PRAGMA table_info("faq_categories") | |
~ (0.000243) CREATE TABLE "faq_categories" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "parent_id" INTEGER DEFAULT 0, "name" VARCHAR(100), "description" VARCHAR(50) DEFAULT '', "url_slug" VARCHAR(50), "position" INTEGER) | |
~ (0.000006) PRAGMA table_info("faqs") | |
~ (0.000097) CREATE TABLE "faqs" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "faq_category_id" INTEGER, "question" VARCHAR(250), "answer" TEXT, "position" INTEGER) | |
~ (0.000038) INSERT INTO "faq_categories" ("parent_id", "name", "description", "position") VALUES (0, 'A', 'A description', 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Client | |
include DataMapper::Resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## DataMapper 0.10.2 & ASSOCIATIONS | |
# | |
# I'm working on a Client model, and need to track the Nationality of the Client, | |
# but don't really want to create an un-necessary Nationality model, when I theoretically | |
# can use the existing Country model. | |
# | |
# All the variations I've tried causes a similar error: | |
# | |
# Cannot add a NOT NULL column with default value NULL (DataObjects::SyntaxError) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needed to import datamapper and other gems | |
require 'rubygems' | |
require 'pathname' | |
# Add all external dependencies for the plugin here | |
gem 'dm-core', '~> 0.10.0' | |
require 'dm-core' | |
gem 'dm-validations', '~> 0.10.0' | |
require 'dm-validations' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## dm-is-list/spec/integration/constrained_spec.rb | |
## NB!! These tests fail. | |
# They are incorporated just to show the problem. IF you know how to fix this issue, please do so. | |
require 'pathname' | |
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper' | |
if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES |