forked from altrabio/CITIEsForRAILS
-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Using:
- ruby 1.8.7
- rails 3.2.9
- citier 0.1.15
- rails_sql_views, :git => 'git://github.com/DouweM/rails_sql_views.git' (others dit not work)
- sqlite Adapter
When I call update_all on a acts_as_citier child class with additional attributes
I get:
ActiveRecord::StatementInvalid: SQLite3::SQLException: cannot modify view_ecm_references_item_pictures because it is a view:
UPDATE "view_ecm_references_item_pictures"
SET "updated_at" = '2012-12-11 13:28:02.581609'
WHERE "view_ecm_references_item_pictures"."id" IN (SELECT "view_ecm_references_item_pictures"."id" FROM "view_ecm_references_item_pictures" WHERE "view_ecm_references_item_pictures"."type" IN ('Ecm::References::Item::Picture') ORDER BY position ASC)
The models:
class Ecm::Assets::Asset < ActiveRecord::Base
# acts as citier
acts_as_citier :table_name => 'ecm_assets_assets'
# associations
belongs_to :assetable, :polymorphic => true
# attributes
attr_accessible :assetable_id,
:assetable_type,
:attachment,
:type
def url(*args)
attachment.url(*args) if attachment.present?
end
end
module Ecm::References
class Item::Picture < ::Ecm::Assets::Asset
# database settings
self.primary_key = 'id'
# attachments
has_attached_file :attachment, :styles => { :default_thumbnail => "64x64>", :default => "64x64>" }
# mti
acts_as_citier :table_name => 'ecm_references_item_pictures'
# positioning
default_scope :order => 'position ASC'
acts_as_list :scope => :assetable
# validations
validates_attachment_presence :attachment
end
end
I had to set the primary key on the picture model, otherwise I got errors.This seems strange to me, too.
The problem is that the update_all uses the view when trying to update. AFAIK this is not possible in sql. Any cluse, how to solve this? Any other people, with the same problem?
Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels