
October 11th, 2007, 03:22 PM
|
|
Contributing User
|
|
Join Date: Dec 2003
Posts: 143
Time spent in forums: 2 Days 9 h 20 m 43 sec
Reputation Power: 5
|
|
|
Undefined local variable or method
I am very new to ruby, and trying to get auto complete / predictive text working, but I am getting the error "undefined local variable or method `providers' "
Here is the first box in my view
Code:
<label for="">Provider:</label>
<div>
<%= text_field_with_auto_complete :orders, :provider,
{ :tabindex => 1,:size => 30, :maxlength => 100 },
{ :url => { :controller => :orders,
:action => :auto_complete_for_provider_name},
:indicator => 'ajax-prov-load-ind',
:after_update_element => "function(element,value){$('activation_customer').enable();$('activation_customer').focus();}" } -%>
<span style="display:none;" id="ajax-prov-load-ind"><%= image_tag 'ajax-load-ind.gif', :style => 'vertical-align:middle;' %></span> <a href="#TB_inline?height=350&width=400&inlineId=add_provider&modal=true" class="thickbox">Add Provider</a>
</div>
And here is the auto_complete_for_provider_name.rhtml, with the bold line where it throws the error.
Code:
<ul>
<% providers.each do |key, value| -%>
<li id="<%=h value -%>"><%=h key -%></li>
<% end -%>
</ul>
here is a snippit from orders controller,
Code:
def auto_complete_for_provider_name
@provider = params[:orders][:provider].downcase
@providers = Provider.call_provider_list_service(@provider)
render :partial => 'auto_complete_for_provider_name', :locals => {:providers => @providers}
end
end
|