Topic: Problem with my show page

Ok I have now got my papers to be able to have an author be selected for them from a drop down box generated in the new paper page 'papers/new.html.erb', which was fixed in an earlier post.

Now I have a problem on the other side of the site, I now want to display a table in the authors show page 'authors/show.html.erb', that displays all the papers made by the specific author shown in the authors show page.

How I plan to do this is by getting the authors controller to only pick from the papers table where the field = the field (both fields being the author name).

So far I have the table set out in the authors/show.html.erb page like this:

<div align="center">Papers owned by the Author</div>

<table border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="#000033" bgcolor="#8A75FF">
    <td bgcolor="#CAC4FF">Paper</td>
  <% for paper in @papers %>
      <td><%=h paper.title %></td>
  <% end %>

And so far the show method for my author controller is displayed as so:

def show
    @author = Author.find(params[:id])
    @papers = Paper.find(:all)

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @author }
      format.xml  { render :xml => @papers }

Obviously all this is going to do is show all the papers in the papers table, rather than the ones whos author = the author name in the authors table.

Could anyone help me with this? I beleive that the change needs to be made in the '@papers = Paper.find(:all)' line in the controller, i just do not know what to replace this line with.

Thanks for any replies.

Re: Problem with my show page

@papers = Paper.find_all_by_author(params = @author[:name])

Re: Problem with my show page

Are you really storing the author's name in the papers table? Why not the author's ID?

Rob Anderton

Re: Problem with my show page

to be honest, it doesn't really matter, this is just for a uni assignment. if it was real I would be using correct field names and types, but for this one it shall remain as a name rather than an ID