進出口新的軌道如何加入這張表?
錯誤
Mysql2::Error: Unknown column 'states.ad_id' in 'where clause': SELECT `states`.* FROM `states` WHERE (`states`.ad_id = 1) LIMIT 1
我的模型
ad.rb
has_one :state
state.rb
belongs_to :ad
這裏是我的表格。
廣告表
+----+----------------+-------------+-------+-----------+
| id | title | description | price | states_id |
+----+----------------+-------------+-------+-----------+
| 1 | ebook | asdasd | 1 | 1 |
| 2 | iphone 4 devol | sdfsdf | 1 | 1 |
| 3 | asd | asd | 1 | 2 |
+----+----------------+-------------+-------+-----------+
狀態表
+----+----------+
| id | name |
+----+----------+
| 1 | Pluto |
| 2 | Mars |
+----+----------+
是的。 belongs_to始終與外鍵保持一致。 – 2011-04-26 04:24:49