Hello everyone,
I’ve got the following scenario
Controller
@things = Thing.find_all
@thing_pages, @things = paginate :things, :per_page => 10, :order_by
=> ‘otherthings.otherthingname, thingname’, :joins => [’,otherthings
where things.id = otherthings.thing_id’]
View
for thing in @things
<%= thing.id %>
<%= thing.thingfield1 %>
What I’d expect to see is a list of the id fields for records in the
things table; instead I’m seeing a list of the id fields for
records in the otherthings table. However, ‘thing.thingfield1’
gives exactly what I want - a list of the thingfield1 fields for
records in the things table.
It seems that the join in the controller code has picked up the id
field from the otherthings table, rather than the id field from the
things table. I’ve confirmed that the model definitions for both
‘things’ and ‘otherthings’ is correct.
Has anyone else encountered this, and/or know of a way around it? I’m
using this block of code all over the place (with different table
names) in my app, and it’s working perfectly everywhere except this
one place.
Thanks in advance
Dave M.