Sample data via Factory_girl

September 26, 2008 @ 06:39 PM | posted by carmelyne

(last updated: 10.01.08)

Cause we like 'em sample data


Maybe trivial to some but the scripts below have been my fallback for populating screens with sample data using Factory Girl via the script console.

1
2
3
4
script/console
require 'spec/factories'
u = User.first
Factory(:pitch, :user => u)

[ Last updated: October 01, 2008 @ 09:38 PM ]

Leave a Reply | or Contact me via email.

Snippets of 06/24/07

Rails 'A'..'Z' Paginate

1
2
3
4
5
6
7
8
9
10
11
# Starts with 'A'..'Z' Paginate / model
def self.sort(sort)
  if sort
    find(:all, :conditions => ['name LIKE ?', "#{sort}%"])
  else
    find(:all, :order => 'name')
  end  
end

# index action / controller
@models = Model.sort(params[:sort]) 

Recent Posts...

RailsConf 2006
I heart devChix