1

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!

1
  • 1
    Your @clients is an Array, not a collection of Clients. Can you post how you set the @clients variable? Also, what version of Rails are you using? Commented Nov 27, 2012 at 16:39

1 Answer 1

1

You have to do something like this

Client.archived.find_each do |client|
Sign up to request clarification or add additional context in comments.

1 Comment

for your information scopes are just like eigen methods in rails you can only call them with specific eigen class name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.