Hey,
I have a main page that lists a table of Devices, along with a Search
box. I’d like to have the Search field pull up any related Devices,
and then re-populate the table.
I can do this without AJAX, just calling my List action over again,
passing the params to search on, but with AJAX I get the error,
“Cannot convert nil to string” on this line:
@device_pages, @devices = paginate( :devices,
:conditions => [“description like
?”,’%’+params[:description]+’%’],
:per_page => 10)
It is falling apart on the ‘+’ portion. Can anybody help with the
process of this? All the AJAX examples I’ve seen only render one line
of text, not a whole group of dynamic text.
My List html:
<%= form_remote_tag(:update => “results”,
:url => { :action => :search },
:position => “bottom” ) %>
<%= text_field_with_auto_complete :device, :description %>
Description
<%= submit_tag “Search” %>
<%= end_form_tag %>
<% if params[:description] %>
Results for '<%=h params[:description] %>'
<% end %>My ‘search’ rhtml:
<% for device in @devices %>
<tr>
<td><%=h device.make %></td>
<td><%=h device.model %></td>
<td><%=h device.description %></td>
<td><%= device.person.fname %> <%= device.person.lname %></td>
<% end %>
My DevicesController for the two actions:
def list
device_pages, @devices = paginate :devices, :per_page => 10
end
def search
@device_pages, @devices = paginate( :devices,
:conditions => ["description like
?",’%’+params[:description]+’%’],
:per_page => 10)
end
–
- Nic