我的應用程序出現新問題。Rails:SQLite3 :: SQLException with has_and_belongs_to_many關聯
我儘量讓一個關係多到許多這樣的:http://guides.rubyonrails.org/association_basics.html#the-has_and_belongs_to_many-association 這裏我用has_and_belongs_to_many「連接」兩個表:用戶&銷
但是當我嘗試數數我得到這個錯誤用戶的引腳。
Showing /app/views/shared/_users_pins.html.erb where line #4 raised:
SQLite3::SQLException: no such column: pins_users.user_id: SELECT COUNT(*) FROM "pins" INNER JOIN "pins_users" ON "pins"."id" = "pins_users"."pins_id" WHERE "pins_users"."user_id" = 102
line 4 : <%= @user.pinss.count %>
(我需要使用pinss而不是銷,否則軌搜索類引腳,而不是銷,但它是如此骯髒的:'()
這裏是我的模型:
class Pins < ActiveRecord::Base
attr_accessible :describe, :title, :url_img
has_and_belongs_to_many :users
end
class User < ActiveRecord::Base
attr_accessible :name, :email, :password, :password_confirmation, :team_id
has_and_belongs_to_many :pinss
end
謝謝!=)
最好。