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?

2
  • Is Ride.all(:conditions => "completed = false") not working either ? Commented Jan 2, 2013 at 3:50
  • could you post your view code as well Commented Jan 2, 2013 at 5:14

1 Answer 1

1

try using Ride.find_all_by_completed(bool)

Sign up to request clarification or add additional context in comments.

3 Comments

Same issue, and I double checked my view to make sure I hadn't misspelled anything.
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.
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!

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.