In my controller, I'm trying to get all requests that are associated with each key, which are associated with some user.
class PendingsController < ApplicationController
# GET /pendings
# GET /pendings.json
def index
@pending_requests = current_user.keys.reduce do |key|
key.requests.where(ready: false).to_a
end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @pending_requests }
end
end
However, at @pending_requests, "there is an undefined method 'requests' for []:Array"
There are multiple keys associated with some user, and multiple requests associated with some key.
In the debugger, the key.requests is recognized as a Mongoid relation, but still fails.
Why is this?