# Undefined method

**URL:** <https://discuss.rubyonrails.org/t/undefined-method/19176>\
**Category:** rubyonrails-talk\
**Created:** [October 12, 2007, 4:02am UTC](https://discuss.rubyonrails.org/t/undefined-method/19176 "2007-10-12T04:02:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Pratt](https://avatars.discourse-cdn.com/v4/letter/w/9dc877/32.png) [@William\_Pratt](https://discuss.rubyonrails.org/u/William_Pratt)\
**Post date:** [October 12, 2007, 4:02am UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/1 "2007-10-12T04:02:57Z")

</div>

How is your Order class setup? Does it have a provider method? In other words, does this return true in script/console:

Order.new.respond\_to? provider

Hallik Papa wrote:

---

<div class="post-metadata">

**Author:** ![William\_Pratt](https://avatars.discourse-cdn.com/v4/letter/w/9dc877/32.png) [@William\_Pratt](https://discuss.rubyonrails.org/u/William_Pratt)\
**Post date:** [October 12, 2007, 4:09am UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/2 "2007-10-12T04:09:24Z")

</div>

If you are wanting something with the same functionality that is not designed around a specific object, you can use text\_field\_tag along with auto\_complete\_field.

William Pratt wrote:

---

<div class="post-metadata">

**Author:** ![William\_Pratt](https://avatars.discourse-cdn.com/v4/letter/w/9dc877/32.png) [@William\_Pratt](https://discuss.rubyonrails.org/u/William_Pratt)\
**Post date:** [October 12, 2007, 5:04am UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/3 "2007-10-12T05:04:39Z")

</div>

Ok, here is the basic deal. The code you are using requires your Order object to have a provider method. This would be either a column in the table, an association, or possible a custom method. Based on the method you are using for autocomplete, you don’t want to use text\_field\_with\_auto\_complete, you need to use a combination of text\_field\_tag and auto\_complete\_field. You can read more about them here:

Hallik Papa wrote:

---

<div class="post-metadata">

**Author:** ![Bob\_Showalter](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@Bob\_Showalter](https://discuss.rubyonrails.org/u/Bob_Showalter)\
**Post date:** [October 12, 2007, 2:23pm UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/4 "2007-10-12T14:23:38Z")

</div>

> I am not sure how to run that command. I tried it from dos prompt in project dir home doing this and didn't seem to execute anything
> 
> script:console Order.new.respond\_to? provider

You do it like this:

C:\myproject\>ruby script/console

> >

The "\>\>" is the console prompt. Now you can enter Ruby expressions in the context of your Rails environment:

> > Order.new.respond\_to? :provider

=\> false

(note that respond\_to? takes a symbol, so you need ":provider", not "provider")

Learn the console. Love it. :~)

HTH

---

<div class="post-metadata">

**Author:** ![William\_Pratt](https://avatars.discourse-cdn.com/v4/letter/w/9dc877/32.png) [@William\_Pratt](https://discuss.rubyonrails.org/u/William_Pratt)\
**Post date:** [October 12, 2007, 8:42pm UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/5 "2007-10-12T20:42:34Z")

</div>

That was my bad. I should have explained the console better. Btw, respond\_to? will attempt to convert it’s argument to a symbol, so anything responding to to\_sym should work:

> > User.new.respond\_to? ‘login’

=\> true

> > User.new.respond\_to? :login

=\> true

-Bill

Bob Showalter wrote:

---

<div class="post-metadata">

**Author:** ![Bob\_Showalter](https://avatars.discourse-cdn.com/v4/letter/b/c57346/32.png) [@Bob\_Showalter](https://discuss.rubyonrails.org/u/Bob_Showalter)\
**Post date:** [October 12, 2007, 9:28pm UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/6 "2007-10-12T21:28:15Z")

</div>

Right, but

&nbsp;&nbsp;&nbsp;User.new.respond\_to? login

isn't correct, and that's what he was using.

---

<div class="post-metadata">

**Author:** ![William\_Pratt](https://avatars.discourse-cdn.com/v4/letter/w/9dc877/32.png) [@William\_Pratt](https://discuss.rubyonrails.org/u/William_Pratt)\
**Post date:** [October 12, 2007, 10:00pm UTC](https://discuss.rubyonrails.org/t/undefined-method/19176/7 "2007-10-12T22:00:25Z")

</div>

Very true. I missed that. Have a good weekend.

Bob Showalter wrote:
