레일스에 처음 생겼어. 이것이 어리석은 질문이라면 용서해주십시오. - 내가 잘못 시작했는지에 대한 충분한 답을 함께 모을 수는 없습니다. . 여기에 간다. 레일 대용량 지정 제한으로 인해 스캐 폴딩 된 참조가 저장되지 않는다
- 은 내가
rails g scaffold Company name:string description:text location_city:string location_state:string accounttype:references
내
Company
모델에 관련된 모든 것을 창조 내가rails g scaffold Accounttype id:primary_key name:string price:decimal
내
Company
모델로Accounttype
모델에 관련된 모든 따라서 다음과 같은 수당이 포함되어 생성 :을
,210belongs_to :accounttype
attr_accessible :description, :location_city, :location_state, :name
내가 회사 내 발판으로 생성 된 편집 형태로 이동하여 해당 필드에 데이터를 입력, 그것은 오류가 발생합니다 :
Can't mass-assign protected attributes: accounttype
내가
:accounttype
attr_accessible
에 추가하는 경우를, 그것은Accounttype(#70175254242100) expected, got String(#70175215042700)
를 던졌습니다{"utf8"=>"✓", "authenticity_token"=>"oXm3cqo0jemKYFB5OGqn5ixXLSB+bH19/1RhPUu0ZHU=", "company"=>{"name"=>"Acme Corp", "description"=>"a", "location_city"=>"san diego", "location_state"=>"california", "accounttype"=>"1"}, "commit"=>"Create Company"}
두 모델을 연결하기 위해 :references
을 사용했는데 문제가 있습니까? 그게 내가 그걸 사용했다면 괜찮은지, 그럼 내가 만들고/작동하도록 업데이 트하려면 어떻게해야합니까?
철저한 답변을 위해 jason에게 감사드립니다. 그러나 이러한 변경을하더라도 여전히 동일한 오류가 발생합니다. '보호 된 속성을 대량 할당 할 수 없습니다 : accounttype' – Kristian