I have some difficulties with text_field_with_auto_complete. Im new to
this, it just will not work, I must be doing something wrong. It would
be great if someone could advise me. I have tried to follow advice
available on the internet, so I dont know what the problem is. The
script gets as far as the breakpoint in the controller, but it doesnt
like the next line giving the error message undefined method or local
variable search. This is what I have
I have downloaded the .js files from aculo and followed their
instructions. I have put the .js files in a folder called Javascripts
in the root of my application.
My table is called institutions and the field is called name
I have added the following to the head of my layout:
<%= javascript_include_tag :defaults %>
<script src="javascripts/prototype.js"
type="text/javascript"></script>
<script src="javascripts/scriptaculous.js"
type="text/javascript"></script>
My view is called place and is the following:
<table>
<tr>
<td>
<%= text_field_with_auto_complete :institution, :names, { :size
=> 15 }, :skip_style => true -%>
</td>
</tr>
</table>
In the controller I have:
def place
end
def auto_complete_for_institution_names
search = params[:institution][:names]
breakpoint
@institutions = Institution.search(search) unless search.blank?
render :partial => "live/search"
end
Then I have a partial called _live.rhtml, which contains:
<ul class="autocomplete_list">
<% for institution in @institutions.to_a -%>
<li class="autocomplete_item"><%= institution_link
institution.name,
institution %></li>
<% end -%>
</ul>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi I still haven''t managed to resolve this issue, is this in some way related to the rails helpers or something??? Darren -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i just did this too. (Rails version 1.1.6)
i used the advance version
http://demo.script.aculo.us/ajax/autocompleter_customized (basic
http://demo.script.aculo.us/ajax/autocompleter)
i have an item that i want to associate to a project.
in the head of my layout I only call
<%= javascript_include_tag :defaults %>
I did not create a javascript folder
view
-----------------------------------------------------------------
<%= start_form_tag :action => ''associate_to_a_project'',
:id => @item %>
<%= text_field_with_auto_complete :item, :project_id, {} %>
<%= submit_tag ''add'' %>
<%= end_form_tag %>
-----------------------------------------------------------------
controller
------------------------------------------------------------------
def associate_to_a_project
@item = Item.find(params[:id])
@item.project =
Project.find_or_create_by_name(params[:item]["project_id"])
if @item.update_attributes(params[:item])
flash[:notice] = ''Project was successfully associated to
item.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def auto_complete_for_item_project_id
auto_complete_responder_for_projects params[:item][:project_id]
end
private
def auto_complete_responder_for_projects(value)
@projects = Project.find(:all,
:conditions => [ ''LOWER(name) LIKE ?'',
''%'' + value.downcase + ''%'' ],
:order => ''name ASC'')
render :partial => ''projects''
end
------------------------------------------------------------------
view _projects
------------------------------------------------------------------
<ul class="projects">
<% for project in @projects do -%>
<li><%=h project.name %></li>
<% end -%>
</ul>
------------------------------------------------------------------
and it worked. It did take me sometime to get scriptolicious''
instructions to work for my app but it was just figuring out what
variable to change/pass
hth
John
On 1/25/07, Darren Evans
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Hi
>
> I still haven''t managed to resolve this issue, is this in some way
> related to the rails helpers or something???
>
> Darren
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---