Forum: Ruby on Rails strange MySQL data populating

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E25296bf52723dc37bc462271eb02d2d?d=identicon&s=25 Jason Pfeifer (jpfeifer)
on 2006-05-16 03:26
I am getting weird data when trying to use HABTM.

I have a Images table with columns id, title, and file.
I have a Categories table with columns id, name.
I have a join table for them with image_id, and category_id

when I do @images.inspect I get:

[#"image 1", "id"=>"52", "portrait"=>"0",
"file"=>"balcony_flowers.jpg"}>, #"image 2", "id"=>"53",
"portrait"=>"0", "file"=>"autumn_parked_car.jpg"}>, #"image 3",
"id"=>"54", "portrait"=>"0", "file"=>"autumn_parked_car.jpg"}>]

which is strange because shouldn't it come out 'title'=>'image 1' and
not #'image 1'?

Though if I loop and do
<% for image in @images %>
<%= image.title %>,
<% end %>

I retrieve Image 1, Image 2, Image 3

Anyway, I guess the join table doesn't come into play, but I originally
thought it might have something to do with it.

Help is much appreciated!

Jason
This topic is locked and can not be replied to.