This is a bit of a rough edge with habtm associations and another good
reason why :though will be a better replacement.
The post_id is a value which is picked up in the join table, its not
part of the authors model. Because of this active record cannot figure
out what the column type is supposed to be: it doesn''t exist on the
Authors table.
Because of this it will just be returned as string.
On 1/9/06, Derrick Spell <derrickspell@cdmplus.com>
wrote:> Greetings made men of rails!
>
> I am presently writing a new database adapter for rails to bring the
> OpenBase community on board. In working through the rather extensive
> AR tests (which I very much appreciate), I have come across a
> question I can''t seem to answer on my own.
>
> In the test_has_many_with_piggyback(AssociationsJoinModel) the result
> is expected as a quoted integer "2". My adapter is returning it
as
> an unquoted integer. What I can''t figure out is why this is
expected
> to be quoted. Since these little things are sometimes symptomatic of
> a larger, more fundamental problem with the way I''m handling
things,
> I thought I should ask.
>
> For your convience, here is the test in question:
>
> def test_has_many_with_piggyback
> assert_equal "2",
categories(:sti_test).authors.first.post_id
> end
>
>
> -Derrick Spell
>
> "Perl''s grammar can not be reduced to BNF.
> The work of parsing perl is distributed between
> yacc, the lexer, smoke and mirrors.''''
> -Chaim Frenkel
>
>
> _______________________________________________
> Rails-core mailing list
> Rails-core@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-core
>
--
Tobi
http://jadedpixel.com - modern e-commerce software
http://typo.leetsoft.com - Open source weblog engine
http://blog.leetsoft.com - Technical weblog