#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    146
    Rep Power
    11

    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
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    7
    Rep Power
    0
    Humm, in your view, you may need to:

    @providers.each do |blahblahblah|
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    146
    Rep Power
    11
    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.

IMN logo majestic logo threadwatch logo seochat tools logo