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
Gadgetoid has quit [Ping timeout: 264 seconds]
Spockz has joined #datamapper
mbj has joined #datamapper
v1n has quit [Ping timeout: 252 seconds]
lgierth has quit [Read error: Connection reset by peer]
lgierth has joined #datamapper
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
v1n has joined #datamapper
lgierth has quit [Quit: Ex-Chat]
v1n has quit [Ping timeout: 252 seconds]
mbj has quit [Quit: leaving]
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
postmodern has quit [Quit: Leaving]
lgierth has joined #datamapper
lgierth has quit [Client Quit]
lgierth has joined #datamapper
lgierth has quit [Quit: Ex-Chat]
lgierth has joined #datamapper
lgierth has quit [Quit: Ex-Chat]
v1n has joined #datamapper
v1n has quit [Ping timeout: 240 seconds]
lgierth has joined #datamapper
cookieboyfan has joined #datamapper
cookieboyfan has quit [Quit: Page closed]
oshura has joined #datamapper
oshura has quit [Ping timeout: 240 seconds]
cvkline has joined #datamapper
lgierth has quit [Quit: Ex-Chat]
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
mbj has joined #datamapper
<cvkline> Hey, question... if I have a class Schedule that includes "belongs_to :carrier" then how do I create a new schedule that includes which carrier it belongs to?
<cvkline> Schedule.create(name: "northbound", carrier: { name: "Local Bus Company" }) doesn't work; it creates a new Carrier rather than find the existing row with that name.
<cvkline> And c = Carrier.first(name: "Local Bus Company") ; Schedule.create(name: "northbound", carrier: c) just blows up.
<cvkline> I guess I'm unclear on how I create new child objects of a parent class that refer to an existing parent.
<cvkline> I just answered my own question...
<cvkline> I was doing c = Carrier.all(name: "Local Bus Company") which returns an array of Carriers, not a single one, even if only one result happens.
<cvkline> So after that, Schedule.create(name: "northbound", carrier: c[0]) works.
<cvkline> And of course so does using .first instead of .all
v1n has joined #datamapper
<mbj> cvkline: carrier = Carrier.find ...
<mbj> carrier.schedules.create(.....)
<mbj> Should be the "most clean" version.
<cvkline> Ohhh, I understand.
<cvkline> Starting at the top of the tree.
<cvkline> I'm porting a "traditional" SQL-based application over, and it's hard to keep thinking in this object-oriented way when it's all been SQL select statements.
<cvkline> Thanks
<mbj> cvkline: np, have fun!
<mbj> cvkline: When working with DM (Or any other ORM) you should think in terms of the domain, not in terms of the SQL. This holds for 99% of the cases, till the ORM abstraction leaks.
<cvkline> hm...
<cvkline> irb(main):023:0> ctest.schedules.new(name: "1100", capacity: 11)
<cvkline> NoMethodError: undefined method `schedules' for #<Enumerator: Carrier:find({:abbrev=>"ISH"})>
<cvkline> from (irb):23
<cvkline> from /usr/bin/irb:12:in `<main>'
<cvkline> mbj: I get that concept, it's just hard to keep the mental discipline. :)
<mbj> cvkline: Carrier.first
<mbj> cvkline: not Carrier.find, sorry. My dm-1 days are "long" over :D
<mbj> Carrier.find returns an enumerator (as you just saw).
rsim has joined #datamapper
<cvkline> Ha, yup, thanks.
<cvkline> I'm intrigued by what i'm seeing about dm-2 or "rom" I guess it's called now. But it seems far from ready for prime time.
<mbj> cvkline: heh
<mbj> cvkline: We are all to busy commercially.
<mbj> OSS work is a chicken egg problem.
<cvkline> I totally get how that goes.
<mbj> ROM would help my clients a LOT.
<mbj> If ROM would exist, I'd probably have more time for OSS.
<cvkline> As much as I've kept trying to learn "modern" web frameworks like this, I kept never having time. Now that I have a consulting gig to redo a crappy old PHP+MySQL spaghetti code application, I am way more motivated!
<mbj> ;)
<cvkline> Anyway, thanks again for your help.
<mbj> k, have fun!
<mbj> If you are interested in ROM, join the #rom-rb channel.
<mbj> Sometimes there is activity ;)
<cvkline> heh ok
rsim has quit [Ping timeout: 245 seconds]
rsim has joined #datamapper
v1n has quit [Ping timeout: 252 seconds]