Hello All,
I am new to Rails and am unable to figure out how to do multiple table
queries to a database using autocomplete
forms.
I have :
Author habtm Books through Works || Book has_many Chapters ||
Chapter has_many Sections
And a table unrelated to these directly called Keywords.
How can I create a page where I provide autocomplete boxes for each of
these so that a user can choose for a
particular keyword/s, author/s and book/s using Boolean logic? (one
view with multiple table search boxes)
ex: keyword ‘civilization’ AND/OR/NOT author ‘Jay’ AND/OR/NOT book
‘xyz’
I was able to create multiple choice autocomplete boxes using the
following code:
<%=javascript_include_tag :defaults%>
Search for Authors
<% form_for :author, :url =>{:action => "show", :controller => "author"} do |form|%> <%= text_field_with_auto_complete :author, :name, {},{:tokens => [',', '\n']}%> <%=submit_tag "Go", :id => @author%> <%end%>But once I added the tokens options, my show action does not work for
more than one choice (it works fine
when only one author was chosen).
My show.rhtml looks like this:
<% for column in Author.content_columns %>
<%= column.name %>: <%=h @author.send(column.name) %>
<% end %>
Can someone please help me out?
Thanks,
KK