Skip to content
Tags

,

Rails 3 tip

March 8, 2011
SELECT * FROM users WHERE name = "david" LIMIT 20

Rails 2 way:

users = User.all(:conditions => {:name => "david"}, :limit => 20 )

Rails 3 Way

users = User.where(:name => "david").limit(20)
users.where("age > 29")

user.order(:name)
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: