2011-03-29 36 views
2

我得到这个错误:为什么我得到这个参数错误?

ArgumentError in Videos#index 

Showing /rubyprograms/dreamstill/app/views/layouts/application.html.erb where line #15 raised: 

No association found for name `genre'. Has it been defined yet? 

线15:<%= link_to "Profile", profile_path(current_user.profile) %>

类型有资料一has_and_belongs_to_many关联。

我有这个在我的路线:

resources :profiles 
resources :genres 

这是我的风格控制器(我试图使用this autocomplete field与一组预先填充流派:

respond_to :html, :json 

def index 
    respond_with(@genres = Genre.search(params[:q])) 
end 

这是我的类型型号:

has_and_belongs_to_many :videos 
has_and_belongs_to_many :profiles 

scope :search, lambda {|q| where("name LIKE ?', "%q%') } 

这是在我的application.js:

$("#genre_field").tokenInput(genres_path); 

那么,为什么我会得到这个错误,我该如何解决它?

+0

鉴于你有'has_and_belongs_to_many'不应该是'流派'吗? – 2011-03-29 09:41:00

+0

由于调用current_user.profile时发生错误,该问题可能在Profile模型中的某处。我的猜测会是你与流派联系在一起的地方。如果你像你说的那样使用了has_and_belongs_to_many,确保它是复数 – DanneManne 2011-03-29 09:42:12

+0

你的意思是错误? – 2011-03-29 09:42:37

回答

4

由于您有has_and_belongs_to_many您应该复数genre

相关问题