1
我使用sqlit3本地和Postgre爲heroku。Rails3 has_many通過本地工作,但在heroku失敗
一切工作正常,直到我上傳我的文件到heroku。這是我的模型。
class User < ActiveRecord::Base
belongs_to :unit
has_friends
end
class Unit < ActiveRecord::Base
attr_accessible :unit, :floor
has_many :users
belongs_to :block
end
class Block < ActiveRecord::Base
attr_accessible :block, :units_attributes
has_many :units, :dependent => :destroy
accepts_nested_attributes_for :units, allow_destroy: true
belongs_to :postalcode
end
class Postalcode < ActiveRecord::Base
attr_accessible :postalcode, :blocks_attributes
has_many :blocks, :dependent => :destroy
accepts_nested_attributes_for :blocks, allow_destroy: true
belongs_to :neighbourhood
end
class Neighbourhood < ActiveRecord::Base
attr_accessible :name, :streetname, :postalcodes_attributes
has_many :postalcodes, :dependent => :destroy
has_many :blocks, :through => :postalcodes
has_many :units, :through => :blocks
has_many :users, :through => :units
accepts_nested_attributes_for :postalcodes, allow_destroy: true
validates :name, :presence => true
validates :streetname, :presence => true
end
我troubleshooted,發現的問題是與在控制器此方法。
@neighbours = current_user.unit.block.postalcode.neighbourhood.users
雖然@neighbours = current_user.unit.block.postalcode.neighbourhood工作完全正常。
請幫忙,我絕望了,我已經嘗試了一整天Google搜索。
差不多,但是。這是我的用戶模型unit_id,werid。但是,謝謝,我愛你:D – user1627056