I am using the make_resourceful plugin in my Rails app, and attempting to use nested resources.
My controller code looks like this:
class ClientRegionsController < ApplicationController
make_resourceful do
actions :all
belongs_to :client
response_for(:create) do |format|
format.html { redirect_to client_client_regions_path }
end
response_for(:update) do |format|
format.html { redirect_to client_client_regions_path }
end
end
private
def current_objects
@current_objects ||= ClientRegion.paginate(:page => params[:page], :order => "name")
end
end
What I want to get on the index action is all the client_regions for a given client, i.e:
client_1.client_regions
What I am actually getting is all the client regions in the system, i.e.:
ClientRegion.all
I've been scratching my head at this for a while, so I thought I'd ask here.
The weird thing is the other actions work as I expect, it is just the index action that is faulty.
Edit: my routes are defined as
map.resources :clients, :has_many => :client_regions
So the paths are
/clients/1/client_regions
/clients/1/client_regions/new
/clients/1/client_regions/20/edit
etc