2012-10-31 3 views
0

레일에서 API를 작업 중이며 벽에 부딪혔다. 내가 상상하는 바보 같은 것을 놓치고 있지만, 나는 그것을 볼 수 없다.레일 - API와의 제휴

https://gist.github.com/3989396

나는 협회가 연결을 만들 수있는 item.json 전달받을 수 없습니다. Rails가 이들을 연결할 것이라고 생각했습니다. 계정에 대한

답변

1

의 관계는과 같이 고정해야합니다

item.rb :

belongs_to :expense_account, class_name: "Account" 
belongs_to :income_account, class_name: "Account" 

account.rb :

has_many :items, inverse_of: :expense_account 
has_many :items, inverse_of: :income_account