안내 다음,하지만 난 (내가 기록을 전화 했어) 내 게시물 내가 할연결할 수 없습니다 모델이 제대로 레일 내가 레일 가이드를 따라하고
에 댓글을 추가 어디 갇히지 해요 그들이 말하는, 내 서버 출력이 같이
@record = Record.find(params[:record_id])
@comment = @record.comments.create(params[:comment].permit(:body))
redirect_to record_path(@record)
,369 :
Started POST "/records/2/comments" for 127.0.0.1 at 2014-02-28 01:28:27 +0100
Processing by CommentsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"XC40jP5Sh6Chr3uXGoSny04n6KJI6+o8LR+txA6cE1o=", "comment"=> {"body"=>"aaa"}, "commit"=>"Create Comment", "record_id"=>"2"}
Record Load (0.2ms) SELECT `records`.* FROM `records` WHERE `records`.`id` = 2 LIMIT 1
(0.1ms) BEGIN
SQL (0.4ms) INSERT INTO `records` (`created_at`, `updated_at`) VALUES ('2014-02-28 00:28:27', '2014-02-28 00:28:27')
(6.8ms) COMMIT
Redirected to http://localhost:3000/records/2
Completed 302 Found in 24ms (ActiveRecord: 7.5ms)
지금, 나는 ... 내 컨트롤러는 내가 매우 밀접하게 가이드를 따라 한 생각
내가 뭘 잘못하고 있니? 감사!
업데이트 :
UPDATE BTREE : 사용 "index_comments_on_record_id"여기 내 기록에 대한 스키마 및
create_table "comments", force: true do |t|
t.text "body"
t.integer "record_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "records", force: true do |t|
t.string "name"
t.string "surname"
t.integer "weight"
t.integer "desired_weight"
t.integer "height"
t.date "dob"
t.string "city"
t.string "condition"
t.string "allergy"
t.datetime "created_at"
t.datetime "updated_at"
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
end
add_index 등 "의견"을 언급, [ "RECORD_ID"], 이름에서 촬영 여기에, 가이드 레일은 내가 permit
가 배열을 받아 믿고, 또한 당신이 require
문을 사용해야 내 컨트롤러
@record = Record.find(params[:record_id])
@comment = @record.comments.create!(params[:comment].permit(:body))
redirect_to record_path(@record)
레코드 및 설명의 스키마를 공유 할 수 있습니까? –
스키마가 괜찮아 보입니다. CommentsController의 'create'액션을 공유 할 수 있습니까? –
표시된 코드는'CommentsController'' create' 액션입니까? 컨트롤러 이름이 아닌'my controller' 만 언급하면됩니다. 나는 당신이 공유 한 로그마다 데이터베이스에'record'가 생성되고'comment'를 공유 한 코드에서'record'가 생성되지 않았기 때문에 확인하고 있습니다. 불일치가 보이니? –