Forum: Ruby on Rails 2 autocomplete fields

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
piotr (Guest)
on 2005-11-26 20:43
(Received via mailing list)
I've got a problem with these ;]

The second one does not work, does not even request a controller method.
Acts like a usual field... What do I do wrong?

#view

	<tr>
		<td class="required">Key Account Manager:</td>
		<td class="content">
			<%= text_field_with_auto_complete :user, :last_name, {}, :skip_style
=> true %>
		</td>
	</tr>
	<tr>
		<td class="head">Parent Account:</td>
		<td class="content">
			<%= text_field_with_auto_complete :account, :name, {}, :skip_style =>
true %>
		</td>
	</tr>

#controller
   def auto_complete_for_user_last_name
   	value = @params[:user][:last_name]
		@users = User.find(:all,
			:conditions => [ 'LOWER(last_name) LIKE ?',
	    '%' + value.downcase + '%' ],
	    :order => 'last_name ASC',
	    :limit => 8)
	  render :partial => 'users'
   end

   def auto_complete_for_account_name
   	value = @params[:account][:name]
		@accounts = Account.find(:all,
			:conditions => [ 'LOWER(name) LIKE ?',
	    '%' + value.downcase + '%' ],
	    :order => 'name ASC',
	    :limit => 8)
	  render :partial => 'accounts'
   end
This topic is locked and can not be replied to.