Uncategorized

Working with json from rails

Posted in Uncategorized on October 28th, 2009 by paul – Be the first to comment

If we have an array called users which contains a number of User objects sent from our rails app, then looping through this array gives us access to each user object.

for (var i = 0;i<users.length;i++) {
   var user = users[i];
   alert(user.user.name);  //This gives us the name property of the object.
 }

Note that each object in the array is preceeded by the name of the class, hence the double user. syntax.

jquery Boxy close popup

Posted in Uncategorized on October 27th, 2009 by paul – 2 Comments

I use the rather excellent Boxy plugin to do some modal style popups.

If you want to close the popup programatically from within the popup, say from a cancel button, you can do it like so…

<input type=button value="Cancel" onClick="cancel_button(this);">
function cancel_button(popup){
 if(confirm("All changes will be lost")){
  Boxy.get(popup).hide();
 }
}

IE8 compatibility mode and cellpadding, cellspacing

Posted in Uncategorized on September 11th, 2009 by paul – Be the first to comment

I recently had a problem whereby a table with a dynamic number of rows had a space above it that I couldn’t explain initially.

The table was in a modal style dialogue with no markup above it before the start of the div. However, the gap betwen the top of the table and the top of the div was variable, depending on the number of rows in the table. The greater the number of rows, the bigger the gap; so clearly the table rows where the problem. I had set margin and padding to zero but that didn’t do it.

Eventually I tried setting the cellpadding and cellspacing to zero, and that fixed the problem.

This may be very obvious to markup experts but I hadn’t seen this before (or if I had I’d forgotten, hence this reminder).

Only a problem in IE8 in compatibility mode.

stop rails writting fieldwitherrors on error

Posted in Uncategorized on September 1st, 2009 by paul – Be the first to comment

It is usually quite handy to have rails wrap one’s form fields in a div to indicate which ones have an error but sometimes it can be a real pain.

Alex Vollmer shows you how to stop rails adding these extra divs to your form fields.

git: send changed files to github

Posted in Uncategorized on August 20th, 2009 by paul – Be the first to comment

git push origin will send any files one has commited locally to the mast server (eg github).
That is a simplistic explanation however.
git status is handy as it will give you an idea of the, umm, status of the files you are working with…

crontab: command not found

Posted in Uncategorized on July 2nd, 2009 by paul – Be the first to comment

On a centos 5.3  vps I got recently I found that crontab was not installed.

On typing crontab -e to edit root’s crontab I got the error:

crontab: command not found

It seemed odd that this was not installed. Anyway, it took me a few moments to work out what package I needed to install.

yum install vixie-cron

there you go.

bind9 secondary on ubuntu

Posted in Uncategorized on July 2nd, 2009 by paul – Be the first to comment

I needed to setup a new secondary name server as one of mine went down  and I didn’t know if it was every going to come back.

So In installed bind9 on a ubuntu server as per the instructions on this page

One problem I ran into though was a permission denied error when the new secondary server tried to transfer zones from the primary server.

This was fixed by changing the owner of /var/bind from root to bind

The next time the transfer happened it worked just fine.

rails on centos 5.3 notes

Posted in Uncategorized on June 29th, 2009 by paul – Be the first to comment

Getting mysql gem installed:

http://blog.charlesarmour.com/2009/06/24/centos-5-3-ror-install/

When trying to install rmagick I kept getting errors about not being able to find fonts such as arial, verdana etc. I removed the mention of microsft fonts in the file

/usr/lib/ImageMagick-6.2.8/config/type.xml

as per comment #2 on this page and rmagick installed ok
(albeit with a load of warnings, but it seems to be working)

rails flash only on next page

Posted in Uncategorized on June 15th, 2009 by paul – Comments Off

If you only want the flash message to be shown on the first request after it is written to, use

flash.now[:error] = “will only show up once”