dkubb changed the topic of #datamapper to: Datamapper v1.2.0 | Mailing List: http://is.gd/aa9D | Logs: http://is.gd/qWAL7V | DataMapper 2 Renamed to ROM, see #rom-rb for development
cored has quit [Ping timeout: 246 seconds]
snusnu has quit [Quit: Leaving.]
knowtheory has quit [Quit: Computer has gone to sleep]
zombor has quit [Remote host closed the connection]
bobocopy has joined #datamapper
zombor has joined #datamapper
bobocopy has quit [Quit: Leaving.]
dkubb has joined #datamapper
zombor has quit [Remote host closed the connection]
ckrailo has quit [Quit: Computer has gone to sleep.]
postmodern has quit [Quit: Leaving]
ckrailo has joined #datamapper
Ortuna has quit [Quit: Computer has gone to sleep.]
ckrailo has quit [Quit: Computer has gone to sleep.]
rsim has joined #datamapper
rsim has quit [Ping timeout: 240 seconds]
swarmhost has joined #datamapper
<swarmhost> Can someome help me out building a basic set of models with a few relationships? I'm having trouble wrapping my head around it - first ORM I have ever used
<swarmhost> http://collabedit.com/pf4vy if you can, thanks
rsim has joined #datamapper
<dkubb> swarmhost: you're probably better off pasting a link to a gist or pastie
<swarmhost> no problem. http://pastie.org/8077658
<dkubb> this is kind of like private chat, and I tend not to want to provide help via private chat unless the information is sensitive. public discussion is usually better because this channel is logged and it can sometimes help others via google
<dkubb> ok one sec
<swarmhost> yeah, I don't use the chat part of collabedit - just sometimes it's easier for helpers to be able to move around in the code and edit stuff on the fly. :) everyone has their own preference :) I appreciate the help
<dkubb> swarmhost: ok, on the Event side you'd probably get two foreign keys like createdby_id and createdfor_id
<dkubb> depending on how you're loading the models, you may want to use a Symbol for the model name
<swarmhost> a symbol?
<dkubb> also, probably not an issue, but the second argument to belongs_to is the model name, eg: belongs_to :created_by, :Person
<swarmhost> Dir[File.dirname(__FILE__) + '/models/[A-Z]*.rb'].each {|f| require f }
<dkubb> actually, scratch that, use 'Person'
<swarmhost> that's how I am loading models
<dkubb> sorry, I was thinking about something else.. another orm system I'm working on
<swarmhost> no worries
<dkubb> ahh I see, so you're basically requiring them all at once up-front
<swarmhost> yes
<dkubb> you may have issues using the actual constant before it's been loaded. like say Event is required before Person, the Person constant won't exist yet
<dkubb> that's why I said use a String. DM will figure it out when the associations are finalized
<dkubb> so aside from using Strings with the associations, I assume you probably don't know how to associate Person -> Event
<swarmhost> The "use a string".. did I miss something above? I think your only mention is mentioning you mentioned it..
<dkubb> declare those belongs_to relationships like this:
<dkubb> belongs_to :createdby, 'Person'
<dkubb> belongs_to :createdfor, 'Person'
<dkubb> I meant when you pass in the model to belongs_to use a string for the name of the model, not a real constant
<swarmhost> ah, gotcha
<swarmhost> ok, I added that to Events.rb
<dkubb> the constant may or may not be defined at the point in time the belongs_to line is evaluated
<dkubb> if it's not defined it'll blow up on you
<swarmhost> var/lib/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/property.rb:366:in `<': comparison of String with Class failed (ArgumentError)
<swarmhost> thats what my test shows
<dkubb> are you able to update that pastie with what you have or paste a new link?
<swarmhost> sure, I'll do that
<swarmhost> all I added was property :createdby, 'Person' and property :createdfor, 'Person' in the Event.rb
<dkubb> note I said belongs_to above ;)
<swarmhost> do'h!
<swarmhost> ok, the model successfully loads now
<dkubb> sweet
<dkubb> so that's the first part, linking back from the Person to the Event is a bit weird
<dkubb> actually, I guess it's not weird, it's just different
<dkubb> since you have two ways to link into the object
<dkubb> in Person.rb I would test adding something like:
<dkubb> has n, :eventsby, 'Event', :child_key => :createdby_id
<dkubb> has n, :eventsfor, 'Event', :child_key => :createdfor_id
<dkubb> so those basically create a named association to a model, and specify the foreign key on the other model to link to
<swarmhost> the models there did load
<swarmhost> I see,
<swarmhost> seems like a bit of magic.
<dkubb> it's not really
<dkubb> the behaviour is pretty consistent and the logic is conceptually simple
<dkubb> there's some edge cases that make it a bit more complex than it is conceptually, but it's still not super difficult
<dkubb> (I wrote most of the association logic in DataMapper btw)
<swarmhost> well done, sir
<dkubb> so I'm not just saying that without understanding how it works ;)
<swarmhost> I would assume you probably know -something- regardless, as you are the only op here ;)
<dkubb> the hardest things are many to many associations, and joining associations to associations, etc
<dkubb> that stuff hurts my brain
<swarmhost> yeah, that's why i decided to try to learn on a more simple concept like a calendar...
<swarmhost> ok, so, those models load
<dkubb> swarmhost: I noticed you said above this was your first time using an ORM?
<swarmhost> but now my tests fail
<swarmhost> yes, my first time using ORM. I have read and read and read..
<dkubb> before you use those models you probably want to call DataMapper.finalize
<swarmhost> but, it still, just, hasn't *clicked*, so I need to practice
<swarmhost> I did finalize
<dkubb> finalize basically walks all the models, and makes sure things are setup in the background
<dkubb> hmm, ok
<dkubb> did you auto-migrate? I think it's sometimes helpful to look at the schema that is generated
<dkubb> I assume since you haven't used an ORM you've been doing lots of stuff with raw SQL?
<swarmhost> yes, raw SQL
<swarmhost> I'm a boss at writing SQL queries. lol ;)
<swarmhost> *cue special olympics music*
<dkubb> hehe
<swarmhost> dbsetup('sqlite:data/caldata.db', 'upgrade')
<swarmhost> er, wait, ignore that
<swarmhost> thats for the production, not the test suite
<dkubb> what I would suggest is for tests use automigrate
<swarmhost> dbsetup('sqlite::memory:', 'replace')
<dkubb> it will tear everything down and rebuild it all
<swarmhost> that's for my test ^
<dkubb> cool
<dkubb> what kind of failure are you seeing?
<swarmhost> so, it is migrating - thats how I understood it to work so thats why I wrote the dbsetup() stuff
<swarmhost> Event not saved
<swarmhost> when adding test event
<swarmhost> but it doesn't know what person to add it to, as I don't have people
<swarmhost> i s'pose
<dkubb> yeah, by default the foreign key will be NOT NULL
<dkubb> so those two FK's in Event will be NOT NULL
<dkubb> you can override that by specifying :required => false in the belongs_to statement
<dkubb> although in general I would recommend against removing constraints unless it really is a valid state for an event to not be created by or for someone
<swarmhost> yeah the constraint need to be there. to confirm though, it's a good troubleshooting step. I did required=> false, and the tests pass, so the ability is there. now I just need to write my tests better. :)
<dkubb> you can also create an event with a person doing something like: Event.create(:person => { ... required fields for the person ... }, ...)
<dkubb> you could have a hash of valid person attributes somewhere that you reuse
<dkubb> or you can have a person created
<swarmhost> yeah, I'm creating a John Doe at the start of the tests
<dkubb> whoops, sorry, I forgot there's no :person relationship in your Event model. I guess your relationships are :createdby and :createdfor
<dkubb> and yeah, since there's two relationships, creating a John Doe up-front and using it for both is probably better
<dkubb> less work in the db == faster integration tests
<swarmhost> there's the schema it came up with
<dkubb> that seems about right
<dkubb> I would tend to add :required => true on any properties you want to be NOT NULL
<swarmhost> yeah, I plan on massaging
<dkubb> actually in a lot of my projects I change this to the default globally
<swarmhost> oh, speaking of that
<swarmhost> when I set the default string size to 255, it still creats it with the old default
<dkubb> I would do something like DataMapper::Property.required(true) around the point where you turned on raise_on_save_failure globally
<swarmhost> not a big deal, but, i noticed it
<dkubb> hmm, dd it create with the default 50?
<dkubb> *did
<swarmhost> yes
fphilipe has joined #datamapper
<dkubb> did you have to manually alter those columns to be VARCHAR(255) ?
<swarmhost> in the model, they are 255. if I remove the repetition from the model, and add it globally, it still creates them with 50
<dkubb> oh I see
<dkubb> maybe as a test try doing: DataMapper::Property.length(255) *before* the models are required, but after dm-core is required
<dkubb> once the models are defined the property defaults are set. changing the global only changes what new properties will get
<dkubb> likewise if you want to do DataMapper::Property.required(true) you'd do it before the models are required
<swarmhost> ahh
<swarmhost> good info
<swarmhost> where it WAS, was on line 4
<dkubb> yeah so you generally do: require dm-core, set global defaults, require the models, finalize the models
<swarmhost> annd of course, you are right. tested and confirmed :)
<dkubb> excellent
<swarmhost> so the "DataMapper::Model.raise_on_save_failure = true" should be before the models too?
<swarmhost> just for consistency
<dkubb> I think it doesn't matter, but I would tend to do it before everything
<dkubb> I think it's more consistent too
<dkubb> swarmhost: ok I'm going to hit bed now, good night!
<swarmhost> hey, thanks a Lot dkubb =D
<dkubb> np
dkubb has quit [Quit: Linkinus - http://linkinus.com]
solnic has joined #datamapper
splattael has joined #datamapper
zombor has joined #datamapper
postmodern has joined #datamapper
kleech has joined #datamapper
fphilipe has quit [Remote host closed the connection]
Ortuna has joined #datamapper
fphilipe has joined #datamapper
postmodern_ has joined #datamapper
Ortuna has quit [Client Quit]
postmodern has quit [Ping timeout: 246 seconds]
zombor has quit [Remote host closed the connection]
postmodern_ has quit [Quit: Leaving]
postmodern has joined #datamapper
solnic has quit [Quit: Leaving...]
knowtheory has joined #datamapper
fphilipe has quit [Remote host closed the connection]
snusnu has joined #datamapper
kleech has quit [Remote host closed the connection]
kleech has joined #datamapper
snusnu has quit [Quit: Leaving.]
zombor has joined #datamapper
zombor has joined #datamapper
zombor has quit [Changing host]
postmodern has quit [Quit: Leaving]
snusnu has joined #datamapper
zombor has quit [Remote host closed the connection]
kleech has quit [Remote host closed the connection]
kleech has joined #datamapper
kleech has quit [Remote host closed the connection]
kleech has joined #datamapper
kleech has quit [Remote host closed the connection]
kleech has joined #datamapper
kleech has left #datamapper [#datamapper]
cored has joined #datamapper
cored has joined #datamapper
Ortuna has joined #datamapper
snusnu1 has joined #datamapper
snusnu has quit [Ping timeout: 255 seconds]
cored has quit [Ping timeout: 268 seconds]
cored has joined #datamapper
cored has joined #datamapper
cored has quit [Changing host]
knowtheory has quit [Ping timeout: 264 seconds]
knowtheory has joined #datamapper
knowtheory has quit [Ping timeout: 248 seconds]
theCrab has joined #datamapper
zombor has joined #datamapper
Ortuna has quit [Quit: Computer has gone to sleep.]
knowtheory has joined #datamapper
snusnu1 has quit [Quit: Leaving.]
snusnu has joined #datamapper
cored has quit [Ping timeout: 268 seconds]
mikecmpbll has joined #datamapper
_whitelogger has joined #datamapper
cored has joined #datamapper
cored has joined #datamapper
v0n has joined #datamapper
cored has quit [Ping timeout: 240 seconds]
xybre has quit [*.net *.split]
Eiam has quit [*.net *.split]
xybre has joined #datamapper
cored has joined #datamapper
cored has joined #datamapper
cored has quit [Changing host]
banditron has joined #datamapper
xybre has quit [*.net *.split]
cored has quit [Ping timeout: 256 seconds]
xybre has joined #datamapper
cored has joined #datamapper
cored has joined #datamapper
cored has quit [Changing host]
knowtheo1y has joined #datamapper
solnic has joined #datamapper
rsim has quit [Quit: Leaving.]
knowtheory has quit [*.net *.split]
zombor_ has joined #datamapper
zombor_ has quit [Changing host]
zombor_ has joined #datamapper
zombor has quit [Write error: Connection reset by peer]
solnic_ has joined #datamapper
solnic has quit [Read error: Connection reset by peer]
brainopia has joined #datamapper
ckrailo has joined #datamapper
bobocopy has joined #datamapper
theCrab has quit [Quit: Gone Forever!]
bobocopy1 has joined #datamapper
splattael has quit [Quit: Leaving.]
bobocopy has quit [Ping timeout: 256 seconds]
talntid has quit [*.net *.split]
rtyler has quit [*.net *.split]
elskwid has quit [*.net *.split]
ayonix has quit [*.net *.split]
viranch has quit [*.net *.split]
gadgetoid has quit [*.net *.split]
dbussink has quit [*.net *.split]
ChanServ has quit [*.net *.split]
knowtheo1y has quit [*.net *.split]
swarmhost has quit [*.net *.split]
tchebb has quit [*.net *.split]
xargoon has quit [*.net *.split]
Cinchy has quit [*.net *.split]
PolarFox has quit [*.net *.split]
xybre has quit [*.net *.split]
bobocopy1 has quit [*.net *.split]
Frost has quit [*.net *.split]
irclogger_com has quit [*.net *.split]
stormwind has quit [*.net *.split]
abuiles has quit [*.net *.split]
mkf has quit [*.net *.split]
onewheelskyward has quit [*.net *.split]
ckrailo has quit [*.net *.split]
solnic_ has quit [*.net *.split]
jpr5 has quit [*.net *.split]
banditron has quit [*.net *.split]
mikecmpbll has quit [*.net *.split]
fcoury__ has quit [*.net *.split]
kapowaz has quit [*.net *.split]
jeremyevans has quit [*.net *.split]
gix has quit [*.net *.split]
brainopia has quit [*.net *.split]
mouse-_ has quit [*.net *.split]
angelixd has quit [*.net *.split]
bhaak has quit [*.net *.split]
cored has quit [*.net *.split]
franckverrot has quit [*.net *.split]
yeban has quit [*.net *.split]
indrek has quit [*.net *.split]
v0n has quit [*.net *.split]
snusnu has quit [*.net *.split]
didlix has quit [*.net *.split]
nwmcsween has quit [*.net *.split]
namelessjon has quit [*.net *.split]
shingara has quit [*.net *.split]
zombor_ has quit [*.net *.split]
kpwz has quit [*.net *.split]
flori has quit [*.net *.split]
Spockz has quit [*.net *.split]
_whitelogger has joined #datamapper
_whitelogger has joined #datamapper
franckverrot has quit [Ping timeout: 264 seconds]
indrek has quit [Ping timeout: 264 seconds]
yeban has quit [Ping timeout: 264 seconds]
yeban has joined #datamapper
dkubb has joined #datamapper
solnic_ has quit [Quit: Linkinus - http://linkinus.com]
kleech has joined #datamapper
solnic has joined #datamapper
kleech has quit [Ping timeout: 260 seconds]
knowtheo1y has quit [Quit: Computer has gone to sleep]
dkubb|away has joined #datamapper
dkubb has quit [Read error: Connection reset by peer]
ckrailo has joined #datamapper
snusnu has quit [Quit: Leaving.]
mbj has quit [Ping timeout: 260 seconds]
snusnu has joined #datamapper
noca has joined #datamapper
jpr5 has quit [*.net *.split]
solnic has quit [Quit: Linkinus - http://linkinus.com]
zombor_ is now known as zombor
solnic has joined #datamapper
rafaelfranca has joined #datamapper
fcoury__ has joined #datamapper
mbj has joined #datamapper
dkubb|away has quit [Quit: Linkinus - http://linkinus.com]
rsim1 has quit [Quit: Leaving.]
postmodern has joined #datamapper
knowtheory has joined #datamapper
mbj has quit [Ping timeout: 252 seconds]
brainopia has quit [Quit: brainopia]
rsim has joined #datamapper
whitenoise has joined #datamapper
travis-ci has joined #datamapper
<travis-ci> [travis-ci] datamapper/dm-active_model#4 (release-1.2 - 3ef1f14 : Dan Kubb): The build has errored.
travis-ci has left #datamapper [#datamapper]
zombor has quit [Remote host closed the connection]
travis-ci has joined #datamapper
<travis-ci> [travis-ci] Build details : http://travis-ci.org/datamapper/dm-rails/builds/8439390
travis-ci has left #datamapper [#datamapper]
<travis-ci> [travis-ci] datamapper/dm-rails#4 (release-1.2 - ca7d3c1 : Dan Kubb): The build has errored.
travis-ci has joined #datamapper
<travis-ci> [travis-ci] datamapper/dm-active_model#5 (release-1.2 - 54e7098 : Dan Kubb): The build has errored.
travis-ci has left #datamapper [#datamapper]
travis-ci has joined #datamapper
<travis-ci> [travis-ci] datamapper/dm-active_model#6 (release-1.2 - 677a540 : Dan Kubb): The build passed.
travis-ci has left #datamapper [#datamapper]
travis-ci has joined #datamapper
<travis-ci> [travis-ci] Build details : http://travis-ci.org/datamapper/dm-rails/builds/8440469
<travis-ci> [travis-ci] datamapper/dm-rails#6 (release-1.2 - 3843dfe : Dan Kubb): The build passed.
travis-ci has left #datamapper [#datamapper]
knowtheory has quit [Quit: Computer has gone to sleep]
rafaelfranca has quit [Remote host closed the connection]
brainopia has joined #datamapper
brainopia has left #datamapper [#datamapper]
rafaelfranca has joined #datamapper
whitenoise has quit [Quit: This computer has gone to sleep]
whitenoise has joined #datamapper
rafaelfranca has quit [Remote host closed the connection]
whitenoise has quit [Quit: This computer has gone to sleep]
rafaelfranca has joined #datamapper
xybre has quit [*.net *.split]
whitenoise has joined #datamapper
Ortuna has joined #datamapper
xybre has joined #datamapper
rsim has quit [Quit: Leaving.]
rsim has joined #datamapper
zombor has joined #datamapper
zombor has quit [Changing host]
zombor has joined #datamapper
solnic has quit [Quit: Leaving...]
bobocopy1 has quit [Quit: Leaving.]
v0n has quit [Read error: Operation timed out]
rafaelfranca has quit [Remote host closed the connection]
rsim has quit [Quit: Leaving.]