开发者

Problem With Autocomplete field rails

I am trying to implement SO style autocomplete. I am using this gem to download the necessary rails3-jquery-autocomplete.

Here is my controller:

autocomplete :tag, :name 

My layout has this:

<%= javascript_include_tag :defaults, "autocomplete-rails.js"  %>

My routes has this:

resources :posts do
    get :autocomplete_tag_name, :on => :collection    
 end

And my form has this:

<%= f.autocomplete_field :tag_list, autocomplete_tag_name_posts_path, :"data-delimiter" => ', ', :class => "tags" %>

I have the autocomplete-rails.js in my public/javascript folder. Yet for some reason I keep getting this error:

undefined method `autocomplete_field' for #<ActionView::Helpers::FormBuilder:0x0000011cb94ef8>. 

My e开发者_如何转开发nvironment.rb file looks like this:

# Load the rails application
require File.expand_path('../application', __FILE__)

# Initialize the rails application
NutraNation::Application.initialize!

What am I doing wrong? Some help would leave me forever in your debt.


This error is a Rails error, not a javascript error. The error basically means you're calling a helper method (autocomplete_field) that doesn't exist.

Looks like you're not including the auto_complete gem in the right place. Check your %APP_ROOT/config/environment.rb file, and make sure your gem is included there.

Also, make sure you've included any necessary resources in your helper. Install instructions for the gem should explain any/all things you need to check to make sure it's setup correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜