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
chevtchenko has joined #datamapper
chevtchenko has quit [Remote host closed the connection]
skade has quit [Quit: Computer has gone to sleep.]
zombor has quit [Remote host closed the connection]
zombor has joined #datamapper
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
lfox has joined #datamapper
zombor has quit [Remote host closed the connection]
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
lfox has quit [Quit: ZZZzzz…]
rsim has joined #datamapper
rsim has quit [Ping timeout: 245 seconds]
rsim has joined #datamapper
solars has joined #datamapper
dkubb has joined #datamapper
skade has joined #datamapper
skade has quit [Quit: Computer has gone to sleep.]
<dankieless>
just as a note i'm using sqllite not mysql
<lgierth>
there's a NOT NULL constraint on friendships.user_id right?
<lgierth>
in sql i mean
<dankieless>
oh wow... do you think it's validates_presence_of :user
<lgierth>
is the issue that you don't want that constraint, or that there should be no condition in datamapper where that columns is NULL?
<dankieless>
i'm using that to ensure the user that is being called actually exists
<dankieless>
Nope. deleting that line did not work. Sorry, a bit new to this. How could I check if there is a restraint?
<lgierth>
dankieless: regarding validates_presence_of, it only validates that the resource has this property set, it doesn't neccessarily mean that the references record also exists in the database
<lgierth>
s/references/referenced/
<lgierth>
mh let me see
<dankieless>
thank you for the help, much appreciated
<lgierth>
ok i think i understand your code. what columns do the sqlite tables have?
<lgierth>
only those referenced in your code, or more?
<lgierth>
asking because friendships.user_id is not references in the code
<lgierth>
so might only need to remove it from the table
<lgierth>
maybe that's why the one answer on stackoverflow says it's working for them
<dankieless>
Sorry, extremely new to databasing. When you refer to a column, are you referring to an attribute of a model? Like a column of user is :id?
<lgierth>
now, those are attributes/properties
<lgierth>
datamapper connects to a database, or in the case of sqlite, opens a db file
<lgierth>
and the structure of that file isn't automatically equal to the attributes you define in your code using datamapper
rsim has quit [Quit: Leaving.]
<lgierth>
are you using rails or something like that?
<dankieless>
interesting. Well, maybe this is where I screwed up. Initially i did have a :user_id row. However, i deleted it and replaced it with :source and :target id's
<dankieless>
no, sinatra
<dankieless>
everything in the friendship/user model is in the stack code
<lgierth>
ok then the user_id column is probably still in the db file, if you only removed the datamapper code for it
<dankieless>
how do I access the db?
<dankieless>
I have a development.db file that when I click on is gibberish. just delete it?
<lgierth>
yep
<lgierth>
but how did you create the table and column structure in it? dm-migrations?
<lgierth>
ah the tutorial
<dankieless>
hey!
<dankieless>
it worked!
<dankieless>
I just deleted the old db and its runinng. thanks a lot!
<dankieless>
yep, dm-migrations
<lgierth>
so what do you do next time you remove a datamapper attribute from your code? :)
<dankieless>
delete the db :)
<dankieless>
thanks bud, i appreciate it.
<dankieless>
learning one step at a time haha
<lgierth>
no! :)
<dankieless>
what do I do?
<lgierth>
i guess you probably removed it from your Friendship model, and the from the migration, right?
<dankieless>
Well I understand what I did wrong. When I initially built it, i used :user_id. Created that column. Fixed up my code, removed :user_id from the model, but I was naive enough to think that it would handle taking the column out on its own
<dankieless>
ruby has spoiled me too much
<lgierth>
ah ok
<lgierth>
what i meant is that, at some point deleting the db won't be an otpion
<lgierth>
and what you can do then is writing a migration that removes the column
<lgierth>
think of it this way: migrations are like deploys, but for your data
<dankieless>
I think i remember this from when I was screwing around with RoR
<lgierth>
yes rails' migrations are similar
<lgierth>
same concept
<dankieless>
yeah ok I just looked it up. I definitely do.
<dankieless>
If I remember correctly, the rails project came with a migration file
<dankieless>
not the case with sinatra
<lgierth>
that's because sinatra doesn't come with a database layer
<lgierth>
routes, dispatch, and controller are sinatra
<lgierth>
model is datamapper
<lgierth>
and view is also sinatra (the .to_json calls)
<lgierth>
or rather, the .to_json calls are the view
<lgierth>
frails on the other hand covers all of these layers
<lgierth>
rails that is
<dankieless>
are you a datamapper dev?
<dankieless>
excuse me, do you contribute to the development of datamapper*
<lgierth>
no just an experienced user
<dankieless>
what do you do if you dont mind my asking
<lgierth>
and the datamapper developers have move on to developing rom-rb
<lgierth>
with datamapper? at the moment not that much, but for 1.5 years i developed a couple of applications using it at soundcloud
<dankieless>
I meant as a profession, so I'm guessing a programmer
<lgierth>
hehe yes programmer :)
<onewheelskyward>
Is soundcloud sinatra?
<lgierth>
rails, but the rails app got way too big, and we started to split non-core functionality out into background services and sites
<onewheelskyward>
Nice.
<lgierth>
and some of the use datamapper
<dankieless>
One last question... How could I append two database queries? I've just realized that if i was to call user.friendships, it would only return the friendships of the user who is :source_id, not :target_id
akasper has quit [Quit: Leaving.]
<dankieless>
or I could fix this by making a second friendship with the source_id and the target_id reversed, right?
<lgierth>
dankieless: yeah the terminology is a bit mixed up. friendships are usually mutual, while here they're directed from user 1 to user 2
<lgierth>
so it should be called followings actually, and have user.followers and user.followings
<lgierth>
or something like that
solars has quit [Ping timeout: 251 seconds]
mbj has quit [Quit: leaving]
lgierth has quit [Ping timeout: 245 seconds]
zombor has quit [Remote host closed the connection]