tzvika ofek
tzvika ofek

Reputation: 53

Activerecord limit returns NoMethodError

i'm trying to get some results from table in a controller using the limit method.

I did that on the controller:

@articles = Article.limit(5) 

And i got NoMethodError exception : undefined method `limit'

But when i did it that way it worked:

@articles = Article.all(:limit => 5)

Although i saw the first method on ror guides, why it didn't work for me?

Upvotes: 0

Views: 1743

Answers (1)

thargor
thargor

Reputation: 453

Are you using rails 3? The limit method is only available in in Rails versions >= 3.0.

Upvotes: 3

Related Questions