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>
我有一个模型 app/models/profile/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
它说关系不正确,但这在对模型进行命名空间之前非常有效。我在这里忽略了什么?