On Wed, Jul 04, 2007 at 05:47:05PM -0400, John Goulah wrote: > I am having some trouble in both controller and template code accessing > resultset functions off of chained/related objects (because from what I'm > seeing they are not ResultSets but of the type > MyApp::Model::MyAppDB::Tablename).
That's isa MyAppDB::Tablename, not MyAppDB::TablenameResultset or whatever. > For example I can create a ResultSet object directly like: > my $owner = $c->model('MyDB::User')->search({ user_id => $owner_id } ); > > and then I can do for example: > > $owner->some_result_set_method() If it's an RS, call the variable $owners or $owner_rs. Trust me that this will make your life easier. > but I can't do this if I want to chain off another object, such as: > > #not ok > my $owner_id = > $photo_details_rs->first()->owner->some_result_set_method(); > > but... > > #this is fine, just accessing a field > my $owner_id = $photo_details_rs->first()->owner->user_id; The relationship must be returning an object, not a resultset then. Don't confuse the Result (single object) and ResultSet (effectively a virtual collection) objects. There's no reason you can't implement methods on both but they are -not- the same thing. This is why I religiously keep $owner versus $owner_rs coding conventions; it makes it way easier to avoid getting confused :) -- Matt S Trout Need help with your Catalyst or DBIx::Class project? Technical Director Want a managed development or deployment platform? Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ _______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/dbix-class@lists.rawmode.org/