Reddirt
Reddirt

Reputation: 5953

Ruby on Rails scope error

I have a boolean field called "archive" in the table called "clients. In the client.rb, I have:

scope :archived, where(:archive => true)
scope :active, where(:archive => false)

In my clients/index.html.erb, I have:

<% @clients.archived.each do |client| %>

But, I get the error

undefined method `archived' for #<Array:0x007fcb441f7d60>

What am I doing wrong?

Thanks!

Upvotes: 1

Views: 286

Answers (1)

Muhamamd Awais
Muhamamd Awais

Reputation: 2385

You have to do something like this

Client.archived.find_each do |client|

Upvotes: 1

Related Questions