I have an index page that I want to show all the users' profile and their associated photos. I'm using the plugin Paperclip for the photos. In the Profiles controller, I have the instance variable @profile but it shows me the table in the profiles table only and not the photos table.
@profile = Profile.find(:all, :include => :photos,
:joins => "INNER JOIN photos ON photos.profile_id = profiles.id")
The models are shown below:
class Profile < ActiveRecord::Base
has_many :photos
end
class Photo < ActiveRecord::Base
belongs_to :profile
end
What I want to be able to show in the View is something like:
- John's profile (e.g., name, age, sex) - John's picture (e.g., only one picture shown)
- Mary's profile here - Mary's picture shown here
- Bob's profile here - Bob's picture shown here