bpope
unread,Nov 12, 2009, 7:58:06 PM11/12/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to restfulx-framework
Hi,
RestfulX is fantastic! Thank you for your efforts.
I'm trying to get the hang of it on a project, but I've been having
some trouble understanding how the nestedBy option works - or more
specifically why I don't seem to be able to index a collection of
(only) associated records.
I have models like so:
Project
has_many :images
Image
belongs_to :project
And I modified routes.rb to include:
map.resources :projects, :has_many => :images
Then in flex, I'm trying to show just the associated images based on
the selected project:
private function onProjectSelect():void {
project = RxUtils.clone(projectsList.selectedItem) as Project;
projectImages = Rx.models.index(Image, {nestedBy:[project]});
}
with the dataProvider of a list component bound to {projectImages}.
When I test this, the correct url is being sent to the server (http://
localhost/projects/1/images.fxml) and you can see the server receive
"Parameters: {"project_id"=>"1"}". The response, however, always
includes all of the Image records, rather than just the associated
ones (with the matching project_id). Same thing if I bypass flex and
just request the url above in the browser.
Clearly something's not right on the Rails side. Do I need something
special in the controller for this to work? Or is this some kind of
caching issue?
I'm on Rails 2.3.4, in case that's relevant.
Thanks so much,
- Ben