Created
August 19, 2011 16:10
-
-
Save aleksclark/1157210 to your computer and use it in GitHub Desktop.
Sinatra-authentication has n, bug
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 'sinatra' | |
require "digest/sha1" | |
require 'rack-flash' | |
require "dm-core" | |
#for using auto_migrate! | |
require "dm-migrations" | |
require "sinatra/reloader" | |
require 'haml' | |
require "sinatra-authentication" | |
use Rack::Session::Cookie, :secret => 'A1 sauce 1s on a11 yr s' | |
#if you want flash messages | |
use Rack::Flash | |
DataMapper.setup( :default, "sqlite3://#{Dir.pwd}/test.db" ) | |
class DmUser | |
# include DataMapper::Resource | |
property :name, String | |
# property :id, Serial, :key => true | |
has n, :things | |
end | |
class Thing | |
include DataMapper::Resource | |
property :name, String, :key => true | |
belongs_to :dm_user | |
end | |
DataMapper.finalize | |
DataMapper.auto_migrate! | |
bob = DmUser.create(:name => "bob", :email => "[email protected]") | |
bob.save! | |
Thing.create(:name => "green thing", :dm_user_id => bob.id) | |
#this works | |
Thing.first.dm_user | |
#this does not | |
DmUser.first.things |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment