Setting variables via database query in a Rails controller

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?

Answers


try using Ride.find_all_by_completed(bool)


Need Your Help

Need help with repeating/looping in PHP

php mysql loops rows

I have this block of PHP and HTML:

Unrecognized Notation in JS

javascript jquery notation

I have been reading book that deals with writing single page applications in Javascript and I ran through this piece of code:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.