Forum: Ruby on Rails Form nested parameters issue

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
73c6b8b1ef87c072549584c0a9248537?d=identicon&s=25 TuteC (Guest)
on 2007-03-08 05:12
(Received via mailing list)
Hello everyone. I'm doing something similar to the AJAX based search
facility presented the Friends of ED book, but it doesn't work for
non-javascript browsers, so I'm trying to improve it.

The search engine looks like:
<% form_remote_tag :url => { :action => :search } do %> #For non AJAX
  Search: <%= text_field "product", "search" %>
  <%= submit_tag "Buscar" %>
<% end %>
<%= observe_field :product_title,
  :frequency => 1.0,
  :update => 'products',
  :url => { :controller => 'store', :action=> 'search' },
  :with => "'search=' + encodeURIComponent(value)" #AJAX

And this action checks if 'search' has something similar to any
product title in the DB:
def search
  @products = Product.find(:all,:conditions => ["lower(title) like
?","%" + params[:search].downcase + "%"])

Searching for "traxxas" with JS enabled works, and it prints in
development.log the following:
Parameters: {"search"=>"traxxas", "action"=>"search",

With JS disabled development.log shows:
Parameters: {"commit"=>"Filter products",
"product"=>{"search"=>"traxxas"}, "action"=>"search",

So I can't accede to "search"=>"traxxas", which is inside product,
from the search action (params[:search].downcase gets nil.downcase).
How can I figure this out?

Thanks in advance;
Eugenio Costa.
This topic is locked and can not be replied to.