Month: July 2007

Just a quick note about arrays of objects in a Rails web service server

If you want an array of something, e.g. past addresses:

class PersonWrapper < ActionWebService::Struct
member :title ,:integer
# … blah
member :addresses ,[AddressWrapper]
member :employers ,[EmployerWrapper]
end

This will give you an array of past addresses and one of employers. It’s one of those things that’s so obvious it is’t documented – so you can’t find it and don’t know it’s there … I will write a longer post/article/wiki about how easy it is to create a web service with complex objects whe I have time.

Response sent to Register Article about gmail

Here

It’s not free 

Cos you’re reading the ads which are generating cash. 

I don’t mind, because they’re text ads rather than really irritating Flash aminations (El Reg take note??).

I think Guy has a point – I also use MacMail, which is POP3, and it sends a mail when the mailbox starts to get full. It’s not rocket science.

By default POP3 does’t delete with gmail – but it does know that it’s been downloaded so you don’t get it again. That’s part of the point with it …

One thing that annoys me, as a developer, is that I can’t send and receive certain attachments but it’s not that big a deal, really.

My ruby on rails form select won’t work?

Got bit by this again. So, for the record …

If you’re selects are’t working (i.e. you’ve got and ID coming through but it is’t showing in a select box).

Check your types

I had:

 @admin.introducer_id = admin_args[:introducer_id]

and this in the rhtml:

 <% form_for(:admin, @admin, :url => admin_path(“index”), :id => ‘admi’ ) do |f| >
    <
= f.select :introducer_id, @introducer_list, {}, {:onChange => ‘go()’ }%>
<%end%>

The it just was’t working no matter what I did.

Then I noticed that a select that was a list of strings was … so … 

 @admin.introducer_id = admin_args[:introducer_id].to_i

and it started working. This has happened to me before – I had a lookup table that stored the lookup ID in a string (‘cos it could have been a string as well as an ID) and it did’t work then. Stupid, stupid boy. Ruby does’t coerce stuff.

Hope this helps the next person.