1
PostgreSQL 및 네임 스페이스 모델에 대해 잘 모르는 문제가 있습니다.namespaced model + postgresql 문제
@photos = Profile::Photo.where(:attachable_id => id)
이가 발생합니다 :
!! #<ActiveRecord::StatementInvalid: PG::UndefinedTable:
ERROR: relation "profile_photos" does not exist
LINE 1: SELECT "profile_photos".* FROM "profile_photos" WHERE "prof...
^
: SELECT "profile_photos".* FROM "profile_photos"
WHERE "profile_photos"."attachable_id" = 1>
나는이 같은 모델 응용 프로그램/모델/프로필/photo.rb :
class Profile::Photo < ActiveRecord::Base
mount_uploader :file, PhotoUploader
belongs_to :attachable, :polymorphic => true belongs_to :user,
:dependent => :destroy #belongs_to :profile, :foreign_key =>
'attachable_id', :dependent => :destroy
그것은 관계가 잘못된 말한다, 그러나 이것은 일 모델 이름 짓기 전에 완벽하게. 나는 무엇을 여기에서 간과 했느냐?
db의 테이블 이름은 무엇입니까? 당신은 그것이 완벽하게 작동했다는 것을 언급합니다. 실제로'profile_photos'가 아니라면'set_table_name'을 사용해야 할 수도 있습니다. – trh
내 테이블이 profiles_photos로 이름이 변경된 것 같습니다. 지금은 확실하지 않은 여러 줄로 생각했습니다. – Rubytastic