Hi All,
I''m new to ruby on rails and I struggle with a problem in my first
application. I searched the forum (and ofcourse google) but I think it
is just an easy thing that nobody boughters to write down :)
I am building a kind of library application for (fysical) books and
e-books and later I want to add other functions like knowledge
management.
The problem: in the book show page I have a form to add a author with
auto complete:
show.rhtml
...
<form action="/book/addauthor" method="get">
<%= text_field_with_auto_complete :author, :name %></p>
<input name="bookid" value="<%= @book.id %>"
type="hidden">
...
book_controller.rb
class BookController < ApplicationController
auto_complete_for :author, :name, :limit => 5
def addauthor
@book = Book.find(params[:bookid])
@author = Author.find_by_name(params[:authorname])
@book.authors.push(@author)
redirect_to :controller => ''book'', :action =>
''show'', :id => @book
end
When I manually enter the right url with variabels (is it english?)
bookid and authorname it works, but when I use the form the name of the
autocomplete field is author[name] and the url it produces is:
localhost:3000/book/addauthor?author[name]=a4&bookid=1&Submit=Submit
So I get an error and I cannot say @author =
Author.find_by_name(params[:author[name]])
All help is welcome,
With kind regards,
Alexander Ketelaar
alexander.ketelaar@gmail.com
--
Posted via ruby-forum.com.