DRY up controllers with params_to_objects

Posted: September 6th, 2008 | Author: Daniel Higginbotham | Filed under: Programming, Rails | 6 Comments »

The following allows you to get rid of the numerous “Model.find(params[:id])” calls in your controllers. I’m pretty sure I’ve seen similar solutions out there, so if anyone wants to link to those in the comments that’d be helpful.
Read the rest of this entry »


jquery: Remove Default Text Values on Focus

Posted: September 1st, 2008 | Author: Daniel Higginbotham | Filed under: Javascript, Programming | No Comments »
function remove_defaults(){
  $("input[@type=text]")
    .each(function(){
      this.default_value = this.value
    })
  $("input[@type=text]")
    .focus(function(){
      if(this.value == this.default_value) {
        this.value = ""
      }
    })
    .end()
}

$(remove_defaults)