Trying to use this in conjunction with a polymorphic association from my base class, but it's trying to execute some defunct SQL.
My classes:
class Activity < ActiveRecord::Base
acts_as_citier
belongs_to :profile
belongs_to :entity, :polymorphic => true
validates :profile_id, :presence => true
validates :entity_type, :presence => true
validates :entity_id, :presence => true, :uniqueness => {:scope => [:entity_type, :entity_id]}
end
class Activity::SetProfilePhoto < Activity
acts_as_citier
end
And my migrations:
class CreateActivities < ActiveRecord::Migration
def self.up
create_table :activities do |t|
t.string :type, :null => false
t.integer :profile_id, :null => false
t.string :entity_type, :null => false
t.integer :entity_id, :null => false
t.timestamps
end
add_index :activities, [:profile_id, :entity_type, :entity_id]
end
def self.down
drop_table :activities
end
end
class CreateActivityUploadPhotos < ActiveRecord::Migration
def self.up
create_table :activity_upload_photos do |t|
# nothing extra for now, will add more fields later
end
create_citier_view Activity::UploadPhoto
end
def self.down
drop_citier_view Activity::UploadPhoto
drop_table :activity_upload_photos
end
end
And finally, the class where I'm attempting to create the activity. (Everything else in this class works prior to using this, so I've just included the relevant code.)
class Photo < ActiveRecord::Base
belongs_to :profile
after_create :create_activity
def create_activity
Activity::UploadPhoto.create!(:profile => self.profile, :entity => self)
end
end
When the Activity::UploadPhoto::create! method is called, it generates the following SQL errors/queries:
Mysql::Error: Unknown column 'view_activity_upload_photos.entity_id' in 'where clause': SELECT activities.id FROM activities WHERE activities.entity_type = 'Photo' AND activities.entity_id = 1 AND (view_activity_upload_photos.entity_id = 1) LIMIT 1
Trying to use this in conjunction with a polymorphic association from my base class, but it's trying to execute some defunct SQL.
My classes:
And my migrations:
And finally, the class where I'm attempting to create the activity. (Everything else in this class works prior to using this, so I've just included the relevant code.)
When the
Activity::UploadPhoto::create!
method is called, it generates the following SQL errors/queries: