저는 개발 용으로 레일즈 4.0을 사용하고 있습니다. 제목과 내용이라는 두 개의 필드가있는 블로그 모델을 만들었습니다. 내가 테스트를 위해 레일 샌드 박스 콘솔을 사용했다레일 : 삽입 쿼리 : 누락 된 열
class CreateBlogs < ActiveRecord::Migration
def change
create_table :blogs do |t|
t.string :title
t.string :content
# create magic column created_at and updated_at
t.timestamps
end
end
end
:
# == Schema Information
#
# Table name: blogs
#
# id :integer not null, primary key
# title :string(255)
# content :string(255)
# created_at :datetime
# updated_at :datetime
#
class Blog < ActiveRecord::Base
attr_accessible :title, :content
attr_accessor :title, :content
end
여기 내 데이터베이스 마이그레이션입니다 :
여기 내 모델 파일입니다.
b = Blog.new
b.title = "blog"
b.content = "blog"
b.save # return true
다음 날 알 콘솔 : 삽입 쿼리를 의미
INSERT INTO "blogs" ("created_at", "updated_at") VALUES (?, ?) [["created_at", "2014-11-08 04:44:40.966670"], ["updated_at", "2014-11-08 04:44:40.966670"]]
제목과 내용 필드를 벗어났습니다. 디버깅 방법을 모르고이 쿼리가 생성되는 위치를 확인합니다. 또한이 버그를 해결하는 방법을 모르겠습니다. 도와주세요.
감사합니다 :)
직접 디버깅하고 싶다면 byebug gem을 사용해보십시오. https://github.com/deivid-rodriguez/byebug –