Mlle
July 12, 2010, 5:52pm
1
I saw an example of the auto complete field sending a ajax request in
this format that allows a method in the controller to catch all auto
complete ajax requests:
‘/rails/app/auto_complete_for/sample_origin’
but when I use it, the request is
‘/rails/app/auto_complete_for_sample_origin’
My template says this
<%=text_field_with_auto_complete :sample, c, {:skip_style=>true}%>
How can I change it so that the request is ‘/rails/app/
auto_complete_for/sample_origin’ ?
Mlle
July 13, 2010, 10:14am
2
I changed the url in the macros helper file:
:url => { :action => “auto_complete_for”, :id=>"#{object}_#{method}" }
def text_field_with_auto_complete(object, method, tag_options = {},
completion_options = {})
(completion_options[:skip_style] ? “” : auto_complete_stylesheet)
+
text_field(object, method, tag_options) +
content_tag(“div”, “”, :id => “#{object}_#{method}
auto_complete", :class => “auto_complete”) +
auto_complete_field("#{object} #{method}”, { :url => { :action =>
“auto_complete_for”, :id=>"#{object}
_#{method}" } }.update(completion_options))
end
Now I can write a method that applies to all auto complete fields.