in reply to Methods in template toolkit

Without knowing more details about what DBIx:: module you are using I cannot say for sure, however I suspect that the issue you are seeing here is related to return context. Your find method maybe returns one thing in scalar context (a row_object) and another thing in list context? If that is the case TT might be calling it in list context in this case. I know I have been bitten by similar things while using TT and DBIx::Class. In general being very explicit in TT code is the best option.

-stvn

Replies are listed 'Best First'.
Re^2: Methods in template toolkit
by dariusj (Sexton) on Dec 06, 2007 at 14:56 UTC
    stvn: you were right! I was looking at the wrong method - I should have been looking at variant_measurements (a has_many relationship) that can return both a scalar and a list - adding _rs on the end forces it to return a scalar.

    So, the working code is variant.variant_measurements_rs.find(variant.id, type_measurement.measurement_id).value

    Cheers!

Re^2: Methods in template toolkit
by dariusj (Sexton) on Dec 06, 2007 at 14:07 UTC
    Thanks for your reply, actually the find method I'm using is documented here, if I'm reading the docs correctly it should only return a scalar.

    I'm trying to find a workaround for this problem, but this would be the simplest and neatest way to do it, and I don't understand why it's not working... (frustration sets in)!

Re^2: Methods in template toolkit
by dariusj (Sexton) on Dec 06, 2007 at 14:12 UTC
    Should probably add that the primary key is a compound key made up of ($variant_id, $measurement_id)