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);
那麼,爲什麼我會得到這個錯誤,我該如何解決它?
鑑於你有'has_and_belongs_to_many'不應該是'流派'嗎? – 2011-03-29 09:41:00
由於調用current_user.profile時發生錯誤,該問題可能在Profile模型中的某處。我的猜測會是你與流派聯繫在一起的地方。如果你像你說的那樣使用了has_and_belongs_to_many,確保它是複數 – DanneManne 2011-03-29 09:42:12
你的意思是錯誤? – 2011-03-29 09:42:37