나는 다음과 같은 모델이 다음 EventParticipantsController 컨트롤러에이 같은 요청에서 HappyHour 모델을로드 지금대량 할당
create_table "event_participants", :force => true do |t|
t.string "name"
t.string "email"
t.boolean "is_organizer"
t.boolean "is_attending"
t.integer "event_id"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "events", :force => true do |t|
t.string "name"
t.boolean "is_finalized"
t.string "type"
t.datetime "created_at"
t.datetime "updated_at"
end
add_foreign_key "event_participants", "events", :name => "event_participants_events_fk"
:
class EventParticipant < ActiveRecord::Base
belongs_to :event
has_one :user
attr_accessible :name, :email, :is_organizer, :is_attending
end
class Event < ActiveRecord::Base
has_many :event_participants
attr_accessible :event_participants_attributes
accepts_nested_attributes_for :event_participants
end
class HappyHour < Event
end
그리고 해당 스키마를 :
@happy_hour = HappyHour.new(params[:happy_hour])
하지만 어떤 이유로 인해 HappyHour의 event_parti cipants 특성은 실패가
가 EventParticipantsController 번호로 2012-01-25 18시 55분 31초 -0300 처리에 대해 127.0.0.1 "/ event_participants"POST 시작하는 JS 파라미터로 생성 { "happy_hour을"=> { "event_participants"=> { "0"=> { "name"=> "Diego", "email"=> "[email protected]", "is_organizer"=> "true"}, "1"=> { "name"=> "Test", "email"=> "test_email.com", "is_organizer"=> "false"}}}, "add_event_participant"=> "[email protected]"} 경고 : 보호 된 속성을 대량 지정할 수 없습니다. event_participants
무엇이 누락 되었습니까? 나는 일대일 관계에서 관련 객체에 대한 대량 대입에 대한 많은 예제를 발견했지만 일대 다 대다수는 내 사례와 다릅니다.
간단하기 때문에, 에밀리 감사합니다! :) – Anero