0

I want an admin to be able to view a list of Rides on his dash page, admin_dash#index (which iterates through each variable in a table in the typical fashion).

This is the controller for the admin dash:

class AdminDashController < ApplicationController
  def index
    @pending_rides = Ride.find_by_completed(false)
    @completed_rides = Ride.find_by_completed(true)
  end
end

In rails console, these exact searches return the right results. But in the view, both of these variables appear to be nil (not even an empty array). What am I doing wrong?

1 Answers1

1

try using Ride.find_all_by_completed(bool)

Devin Stewart
  • 3,006
  • 1
  • 16
  • 22
  • Same issue, and I double checked my view to make sure I hadn't misspelled anything. – Jennifer Gilbert Jan 02 '13 at 02:40
  • Then the last thing that I'm thinking is that your rails console, and view are not pointed at the same database. Are you running your Rails in Production mode? Because typing rails console puts development mode. – Devin Stewart Jan 02 '13 at 02:49
  • I fixed the issue by trashing and then re-implementing the code -- I must have had an error somewhere, but couldn't find it, and it's a simple enough thing that I figured I'd try doing it over again. Thanks for your help! – Jennifer Gilbert Jan 02 '13 at 08:14