Great forum you have here.
I am pretty new to rails, and I am struggling getting an application up
My application is to have a photo gallery. I have two scaffolds, one for
albums, and one for the photos.
I have the albums section working smoothly, but I am having trouble
linking the both of them together.
I will try to explain my problem.
In the albums sections, I create and album. From the show.html you get
the option to view pictures.
<%= link_to (‘View Pictures’, :controller => ‘photos’, :action =>
‘list’, :album_id => @album.id) %>
from there, you are presented with a list of the photos contained in the
Now, here is my problem.
To get the list of photos contained in an album, I am using the id of
the album to separate the photos.
so in my photos controller I have
@photos = Photo.paginate(:all,
:conditions => [‘album_id = ?’, @album.id],
:per_page => 9,
:page => params[:page])
which i can understand.
The big problem I have is storing the album ID to the new photo.
So from the ‘view pictures’ page, i have a link to 'add a photo, which
is my new.html.erb.
What I can’t do, is store a photo to the database / application, and
have the album_id stored to the photo also.
Every time i add a photo, the album id is not stored.
I have tried to add a hidden field, but whatever I do i cannot pass the
album id over to the new photo.
does anyone have any pointers for me?
I can add any extra bits of code as needed.