Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Winton Welsh http://stu.dicio.us

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

Rails Subversion First Checkout

// I use this for checking out a new rails project

svn checkout http://studicious.com/svn/trunk %1
svn remove log/*
svn commit -m "Removed log files"
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m "Ignoring log files"
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "Ignoring temp folder"

Custom Validation in ActiveRecord

// allows adding errors in methods other than validate

  def other_errors=(err)
    write_attribute(:other_errors,Array.new) if !self.other_errors
    self.other_errors[self.other_errors.length] = err
  end
        
  def other_errors
    read_attribute(:other_errors)
  end

  def validate
    if self.other_errors
      self.other_errors.each {|x| errors.add_to_base(x)}
      return
    end
    return if !errors.empty?
  end
« Newer Snippets
Older Snippets »
2 total  XML / RSS feed