Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To get to the bottom of things, start the rails console with:</p> <pre> $ rails c </pre> <p>Given that Account is an ActiveRecord model, you should be able to do the following in the rails console:</p> <pre> > Account.all.count => 100 > Account.where(:status=>'active') => [ #&lt;Account id: 1, name: "a1", ...>, #&lt;Account id: 2, name: "a2", ...>, #&lt;Account id: 3, name: "a3", ...>, ...] </pre> <p>I'm doing a lot of hand waving here with ... since I don't know your schema. Replace the where condition with whatever works for your situation. The returned value should look like an array with a list of all the rows in the database that match the condition. BTW, an array is a list of element, and inspect (as well as the default display in the console) show element separated by commas. I haven't used debug so I can't comment on what it should do.</p> <p>You can verify that the returned value is an AREL, and should be able to do some other operations to verify things work as expected.</p> <pre> > Account.where(:status=>'active').class => ActiveRecord::Relation > Account.where(:status=>'active').size => 99 > Account.where(:status=>'active').count => 99 > Account.where(:status=>'active').limit(10).count => 10 </pre> <p>If these work as expected in the console, there may be something in the view that is obscuring the correct behavior. In that case you'll need to post the details of your view code. If the strange behavior still occurs in the console, I would suggest posting the minimal parts of the actual model code that still exhibit the problem, along with the migration so we can see the schema.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload