Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 11th, 2007, 03:22 PM
hallik hallik is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 143 hallik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 9 h 20 m 43 sec
Reputation Power: 5
Send a message via AIM to hallik
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

Reply With Quote
  #2  
Old October 12th, 2007, 11:39 PM
tschneit tschneit is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 7 tschneit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 18 m 33 sec
Reputation Power: 0
Humm, in your view, you may need to:

@providers.each do |blahblahblah|

Reply With Quote
  #3  
Old October 14th, 2007, 06:49 PM
hallik hallik is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 143 hallik User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 9 h 20 m 43 sec
Reputation Power: 5
Send a message via AIM to hallik
I was thinking this was like java. I did not know a column in a table could be considered a method. Added a provider column and boosh! It started working.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Undefined local variable or method


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway