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:
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:
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:
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:
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
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:
Right, but
User.new.respond_to? login
isn't correct, and that's what he was using.
Very true. I missed that. Have a good weekend.
Bob Showalter wrote: