text: Q:
  
  Rails: Using form (collection select) to call show-action
  
  A model named 'book' with attributes 'name' and 'id' is given. How can i use this collection select to call the show-action of a certain book? The one code mentioned below returns the following error message:
  Couldn't find Book with ID=book_id
  <% form_tag(book_path(:book_id)), :method => :get  do %>
    <p>
    <%= label(:book, :id, 'Show Book:') %>
      <%= @books = Books.find(:all, :order => :name)
        collection_select(:book, :id, @books, :id, :name) 
    %> 
    </p>
    <p>
    <%= submit_tag 'Go' %>
    </p>
  <% end %>
  
  A:
  
  book_path is generated once only, for the form tag itself. It won't be updated whenever your selection changes.
  When you submit that form, it's going to request the following URL:
  /books/book_id?book[id]=5
  
  Since your book_path thinks book_id is the ID number you wanted, it tries to look that up. You could do what you want you by changing the code in your controller from:
  @book = Book.find(params[:id])
  
  to:
  @book = Book.find(params[:book][:id])
  
  But it kind of smells bad so be warned.
  
  