Rails activeadmin / carrierwave has_many photo relationships throwing a mass assignment exception
I have a BlogPost model defined as
class BlogPost < ActiveRecord::Base
attr_accessible :title, :body, :photo, :photos_attributes, as: :admin
has_many :photos, class_name: 'BlogPhoto', dependent: :destroy
validates :body, :photo, :title, presence: true
validates :title, uniqueness: true
accepts_nested_attributes_for :photos, allow_destroy: true
end
from schema
create_table "blog_posts", :force => true do |t|
t.string "title"
t.text "body"
t.datetime "created_at", :null => false
t.string "photo"
t.datetime "updated_at", :null => false
end
class BlogPhoto < ActiveRecord::Base
belongs_to :blog_post
attr_accessible :photo, as: :admin
mount_uploader :photo, BlogPhotoUploader
end
and an activeadmin form to create a new blog
form do |f|
f.inputs "Blog Post" do
f.input :title
f.input :body, as: :html_editor
end
f.inputs "Photos" do
f.has_many :photos do |p|
p.input :photo, as: :file
p.input :_destroy, as: :boolean, required: false, label: 'Remove Photo'
end
end
f.actions
end
I also use wavewave to upload photos to S3. With all this code, when I try to create a new blog blog inside an active admin, I get a bulk assignment message: Unable to bulk assign protected attributes: title, body, photos_attributes
However, you can see that I have marked the white attributes very clearly, so what could be causing this?
EDIT: Included the following line in
class BlogPost < ActiveRecord::Base
mount_uploader :photo, BlogPhotoUploader
and now the exception is
undefined method `validate_integrity' for :BlogImageUploader:Symbol
0
source to share
No one has answered this question yet
See similar questions:
or similar: