현재 기존 데이터베이스에 대한 관리 도구에서 작업 중이며 특정 테이블을 스캐 폴딩 할 때 이상한 문제가 발생했습니다. 여기 Rails scaffold 이상한 테이블에 대한 이상한 undefined_method 오류
테이블의 스키마는rake db:schema:dump
을 사용하고 있습니다 :
rails g scaffold locality version:integer truth_id:string truth_record_id:string
deleted:binary internal_code:string iso_code:string materialized_path:string
invariant_name:string published:binary geo_point_latitude:float
geo_point_longitude:float class:string hut_count:integer hotel_count:integer
destination_url:string
가이 워크 플로는 다른 많은 근무 :
create_table "locality", :force => true do |t|
t.integer "version", :limit => 8, :null => false
t.string "truth_id", :null => false
t.string "truth_record_id", :null => false
t.binary "deleted", :limit => 1, :null => false
t.string "internal_code", :null => false
t.string "iso_code"
t.string "materialized_path", :null => false
t.string "invariant_name", :null => false
t.binary "published", :limit => 1, :null => false
t.float "geo_point_latitude", :default => 0.0
t.float "geo_point_longitude", :default => 0.0
t.string "class", :null => false
t.integer "hut_count", :default => 0
t.integer "hotel_count", :default => 0
t.string "destination_url"
end
add_index "locality", ["truth_record_id"], :name => "truth_record_id", :unique => true
나는 덤프 된 스키마에서 내 발판을 만들 수
schema_to_scaffold 보석을 사용 테이블하지만 레일스 콘솔에서/localities 또는 Locality.all에 액세스 할 때 나는 그 모든 것을 얻습니다 :
irb(main):001:0> Locality.all
Locality Load (2.1ms) SELECT `locality`.* FROM `locality`
NoMethodError: undefined method `attribute_method_matcher' for "Country":String
"국가"는 어디에서 왔습니까? 처음에는 모델명 '지역성'이 i18n 제품의 레일에 의해 예약되었지만 모델 'Bla'의 이름을 지정할 때 같은 문제가 발생한다고 생각했습니다.
저는 레일즈 3.2.13과 MySQL 데이터베이스를 사용하고 있습니다.
아, 문제를 프로그래머, 내가 뭔가를 분명 실종됐다 생각했다. –