views:

17

answers:

1

Hello,

I have the following rails 3 nested models:

resources :books do
  resources :authors
end

I now have a view here: /books/131/authors/ And I want to each record to link to something like: /books/131/authors/3333

<% @authors.each do |author| %>
   <%= link_to 'author.name', book_author_path(@book, @author) %>
<% end %>

but that error's with: No route matches {:action=>"destroy", :controller=>"authors"}

I also tried:

<%= link_to 'author.name', [@book, author] %>

Problem is the code keeps linking to /authors/3333, not /books/131/authors/3333

Ideas? thanks!

A: 

book needs to be defined in the author controller for def index

<%= link_to "title", book_author_path(@book, author) %>
WozPoz
Question.... In the controller, when for author, def Create right now it redirects to @author... how do I redirect to book_author_path? format.html { redirect_to(@author, .... thxs
WozPoz