Alex Y. wrote:
list and listByArtist are actions, not controllers. The controller is
the class that holds those actions. At least, I assume that’s how
you’ve set this up. It would be the most sensible way, I think.
Yes that is how I have set it up…my terminology is not up to
scratch…if it isnt obvious I am very new to ruby/rails/html.
I placed your suggested code into the listByArtist controller,
It should go in the list action, so that the list view has access to
@artist.
Um…I actually got it to work without adding anything into the list
action.
At least, that’s what’s wrong in theory. Looking at it, I don’t
actually see why you need :id => @artist.id in the start_form_tag call
at all… the ID is going to be provided by the select box anyway.
Yes you are right here - I have not explicityly stated the :id in other
forms and they are working fine. I was just trying to explicitly pass
this id as a brute force attempt to send the id to the listByArtist
action.
You’ll need to change the call in the listByArtist from params[:id] to
params[:artists][:id], but that’s where the value should be coming
from…
So - I now understand where I was going wrong. Thanks for your help
Alex - it has put me straight…
I removed the :id from the start_form_tag in the listByArtist view:
<%= start_form_tag :action => “listByArtist” %>
…and called the variable artist instead of artists (just cleaning up):
…and I added this to the listByArtist action:
def listByArtist
@song = Song.find(:all, :conditions => [ "artist_id =
?", params[:artist][:id] ])
@artist = Artist.find(params[:artist][:id])
end
I did not change the list action as you have suggested. This did not
seem necessary to me as the only two arrays of data being used by the
list action were song and artists. So I left this alone.
I really need to learn about using a debugger to be able to quickly
establish what is going wrong.
Anyway - thank you for your help!
A