ruby on rails country_options_for_select helper
So I’m still working away on this project using Ruby on Rails, and generally I’m loving it. It really is a great piece of software. Progress is good, but I often find myself stumbling on what should be the simple things.
Today for example, I wanted to use the country_options_for_select() form helper to generate a list of countries as a dropdown in a form, with a number of countries prioritised at the top of the list.
The list was being generated but the prioritised countries where not be generated. The code I had was something like this:country_options_for_select(priority_countries = ['United Kingdom','United States']).
Now the method signature in the api docs is this: country_options_for_select(selected = nil, priority_countries = nil), and I assumed that the selected = nil didn’t need to be included as it was the default.
Not so. Once I added the selected = nil argument to the method it worked.
And the lesson is?
Assumption is the mother of all feck ups I guess.
How to properly turn off comments
I was still having problems with getting sh*t loads of spam via the old posts on this site, even though I had turned off all commenting in the admin as far as I could tell. Seems I needed to sort out some settings on the old posts. Info on this can be found in this post on the wordpress site.
Specifically:
UPDATE wp_posts SET comment_status = ‘closed’, ping_status = ‘closed’ WHERE comment_status = ‘open’;
Ahhh, peace at last.
Update: and now I can gleefully look at all those feeble attempts to spam me in my logs. :)
turning off comments
I’m getting more comment spam on this blog than email spam to the half dozen or so domains I have registered so I’m just going to turn off comments for now. It’s really annoying but spam just really gets on my nerves, and I really don’t like the idea of these spammers burning up my bandwidth or more importantly my time.
If anyone wants to get in touch with me about this blog or anything else the follow the 'about me' link top right to my main site where there is a contact form...
nesting variables in smarty
Ever need to use nested variables in smarty? I know its not very mvc, but on more than one occassion I’ve found myself needing to . So here is how to do it, as a reminder to myself more than anything tbh.
{{$Availability[$product.stockLevel]}}
Improve Spam detection in Thunderbird mail client
I’ve noticed recently that the junk mail filtering in the Thunderbird mail client wasn’t as good as I would have liked. So I had a hunt around and found this thread on the MozillaZine forums with a good tip to improve its spam detection rules. Warning, involved some hand editing of preference files…
wordpress update
There is a new version of wordpress out, 1.2.1 . It is a bug fix release I believe. I was able to just copy the archive straight into my wordpress folder and all is well. Admin system tells me I am now running the new version.
chkconfig for debian? 1
I recently switched to debian for my linux box at home. I have previously been using redhat (various versions and variants). Most of the boxes I work on and manage are redhat based in some way so I had become familiar with the way it is laid out.
So, I recently installed ddclient to update my dynamic dns records at dyndns as I am on DSL at home with a dynamic IP.
In the installation instructions one is told to use chkconfig to ‘turn on’ ddclient as a service. The problem is that (as far as I am aware) chkconfig does not exist on debian.
Hmm. So a bit of searching led me to the debian policy documtent, which explains the debian equivalent of chkconfig, i.e. update-rc.d . That doesn’t roll off the tongue as easily as chkconfig but it does the job. Specifically check out this page<-nextpage-> for info on how to use it.
In my case I just ran update-rc.d ddclient defaults (after copying the file ddclient from my distribution folder to /etc/init.d ) and it created symlinks from /etc/init.d/ddclient to the various init folders. I suppose I should really have choosen just the runlevels I needed but it was early and I hadn’t quite woken up …
hth.
latest IE scare
Following on from todays revelations that various sites are spreading malware via IE, I’ve just updated my xp pro box to service pack 2, rc2. So far so good. Apparently this patch secures IE against this particular vuln. I must say I’m happy with the improvements so far. If you want to update to sp2 rc2 then you need to update your windows update client here: and then just do windows update as normal. Easy.
wordpress update
I’ve just updated wordpress here form v 101 to 1.2. A few hiccups (should have checked where the tar file was headed…) but everything seems ok now. Some cool new featues too…
welcome back Mr Beattie
Russell Beattie is back, posting away on his blog after a bit of a break. Good stuff.