06:06
<botanicus>
Hey. I'd like to ask how you guys deal with saving multiple objects. I. e. if I have an order and the order has items, how do you save it? As a separate objects and then use order.add_item(item) or sth similar? I have it this way but for more complicated stuff it's really very verbose, especially because of validations handling (since I can't just use order.errors, but also items.each(&:errors) because it doesn't work a
06:06
<botanicus>
s a cascade).
06:10
<injekt>
botanicus: You mean like associations?
06:11
<botanicus>
injekt: yes
06:11
<injekt>
1sec I'll write up an example
06:11
<botanicus>
As if I have orders : items, then order.errors won't include errors for items
06:12
<injekt>
botanicus: Are you currently using associations? Or you want to use them?
06:12
<botanicus>
injekt: yes, I'm using them
06:13
<injekt>
Oh ok, yeah just use order.add_item(item)
06:13
<botanicus>
injekt: But associations in sequel seems to be much more low-level than in DM and I'm not so familiar with it so far.
06:13
<injekt>
botanicus: tbh I've only just got myself used to them. Someone may be able to help you more, I wouldn't want to mislead you.
06:14
<injekt>
jeremyevans perhaps
06:14
<botanicus>
injekt: thanks, I know about it, but then errors for items won't be in order.errors[:item] I think(?)
06:14
<botanicus>
injekt: OK, thanks anyway
06:14
<injekt>
botanicus: What about order.items_dataset.errors?
06:15
<botanicus>
injekt: errors are in sequel model, I'm pretty sure it isn't dataset related
06:16
<injekt>
Ah yeah, see there I go already misleading :) I haven't had as much time as I'd like to get into Sequel unfortunately
06:16
<injekt>
jeremyevans will probably be around at some point, he's generally active most of the time
07:04
<botanicus>
Ah, I have it, when I use plugins/nested_attributes.rb, it should work (at least it seems so)
07:08
<huma>
jeremyevans rocks!
07:08
<huma>
er, i mean he's a very helpful fella :)
08:03
<jeremyevans>
botanicus: Check out the nested_attributes plugin
08:03
<jeremyevans>
botanicus: Seems like you already found it :)
08:05
Swimming_Bird joined
08:08
<djanowski>
hello all. anybody using some sort of to_xml method on models?
08:57
<botanicus>
jeremyevans: yes, I found it, thanks
12:16
<jammi>
jeremyevans: yes, I get that about the charset, but I think it should be mentioned somewhere in the documentation, otherwise it'll just result in a lot of wtf's when people have utf8 databases and receive latin1 data
12:18
<jeremyevans>
jammi: I'll happily accept documentation patches :)\
12:19
<jeremyevans>
jammi: And the encoding you get is determined by the underlying driver, so if you want the problem fixed, you should talk to the ruby-mysql developer if you are using the native mysql adapter
12:22
<jammi>
well, it wasn't such a big issue for me, because I've used ruby-mysql before. the issue was just to find the execute method
12:23
<jammi>
however, a random ruby newb would certainly have issues about it
12:23
<jammi>
(or mysql newb)
12:23
<jammi>
because google doesn't really help there
12:30
<jammi>
and no, I'm sorry: I have my own projects to patch; not much spare time cloning, hunting down and patching random libraries :/
12:48
<jeremyevans>
jammi: Fair enough
13:00
Swimming_Bird joined
13:50
<NemesisD>
jeremyevans: ping, i'm not sure if this is even a sequel issue but for some reason my tests don't run at all, the program just exits like nothing happened
http://pastie.org/870864
13:55
<jeremyevans>
NemesisD: I haven't used shoulda, Can you make sure that the should blocks are actually getting executed?
13:56
<jeremyevans>
NemesisD: And the ADO adapter doesn't support transactions
13:57
<jeremyevans>
NemesisD: Not sure if that matters to your app, but if you can use ODBC instead of ADO, I'd recommend it
13:57
<NemesisD>
hmm turns out they definitely aren't being executed
13:57
<jeremyevans>
NemesisD: So it's probably an issue with shoulda or test/unit
13:57
<NemesisD>
jeremyevans: ah ok, would i have to setup a data source for the odbc adapter
13:57
<NemesisD>
jeremyevans: yeah i think you're right
14:15
<NemesisD>
oh wait now i remember why i didn't use odbc. causes a NoMemoryError on my system (even with the latest sequel)
14:38
<jeremyevans>
NemesisD: I suppose that's a good reason to avoid it
14:39
<NemesisD>
kinda unfortunate, the ado adapter is constantly getting syntax errors
14:39
<NemesisD>
jeremyevans: lol yeah
14:39
<jeremyevans>
NemesisD: ADO doesn't provide a consistant connection to Sequel, so transactions don't work, and potentially other things as well
14:40
<jeremyevans>
NemesisD: If you can use JRuby, the JDBC adapter is the best way to access MSSQL (assuming that is what you are accessing)
14:40
<NemesisD>
jeremyevans: i don't think anything i do uses transactions, the command it chokes on is with Model.dataset.columns so i'm going to set up sql logging and see what its actually giving to sql server
14:48
<NemesisD>
jeremyevans: ah. it does SELECT ([COL1], [COL2]) FROM [TBL];, sql server doesn't want the parentheses. i don't suppose there's an easy way for me to disable this functionality
14:48
<jeremyevans>
NemesisD: What's the code that it's using?
14:49
<jeremyevans>
NemesisD: Sounds like you are passing an array to select instead of separate arguments
14:49
<NemesisD>
ah i think i might need a splat somewhere, sec
14:49
<jeremyevans>
NemesisD: That would make sense
14:50
<NemesisD>
jeremyevans: tricky tricky. it works :D
14:50
<jeremyevans>
NemesisD: Good to hear :)
14:50
<NemesisD>
thanks for your time!
14:50
<jeremyevans>
NemesisD: You're welcome :)
14:51
<NemesisD>
jeremyevans: oh one more quick question. what's the typical workflow for defining a database to be used by models? right now I set the db up as a constant (which i never use) and have to do so before requiring my models. just figured there might be a more idiomatic way
14:52
<jeremyevans>
NemesisD: Nope, that's the recommended way. The convention is to name the constant DB
14:52
<jeremyevans>
NemesisD: You'll see most examples use DB
14:52
<jeremyevans>
NemesisD: If you are only accessing the database through models, you probably won't need to access the model constant directly, through
14:53
<NemesisD>
jeremyevans: ah ok
15:15
merboutpost_ joined
15:32
merboutpost_ joined
18:36
Swimming_Bird joined