开发学到的东西

1.

options = User.all(:conditions => "status <> 3", :order => "firstname, lastname").collect{|x| [x.name, x.id.to_s]}

 

cars = Car.where(:colour => 'black').all   (adding .all means it will load the data with no waiting.)

 

cars = Car.find(1)

cars = Car.find(params[:id])

 

cars = Car.order('created_at ASC')

 

oldest_car = cars.first

newest_car =  cars.last

 

 

你可能感兴趣的:(Ruby,Rails,dev)