hyperoslo / activeadmin_polymorphic Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It won't work if you set config.default_namespace = false
Sorry, didn't notice in readme
In plan
check who it works with: models under a certain namespace
We tried implementing the demo you show, and even with a fair bit of variation and playing with it, we don't see it working. Could you update the docs with a more robust example?
Thank you
Doesn't work with formtastic < 3.0 (possibly 3.1)
Hi,
I have an application with the models Section and Element with polymorphic associations to Paragraph and Image.
class Section < ActiveRecord::Base
has_many :elements
end
class Element < ActiveRecord::Base
belongs_to :section
belongs_to :implementation, polymorphic: true
accepts_nested_attributes_for :implementation
end
class Paragraph < ActiveRecord::Base
has_one :element, as: :implementation
end
class Image < ActiveRecord::Base
mount_uploader :file, ImageUploader
has_one :element, as: :implementation
end
I was able to make the Section form with the Paragraph class. However, with Image class I not able to upload files due to file fields in form are stripped out as you mentioned in the to documentation.
I have already configured carrierwave + remotipart and actually images are uploaded asynchronously from the new image form (outsite the Section form). However, but I was not able to make that work within the Section form. I have noticed that file are still stripped out only when I try to add and send a new Image from the Section form.
Do you have an example or more detailed documentation regarding image uploading?
Thanks in advance
I try out to add gem functionality, but gut an issue (below). Maybe I'm wrong somewhere, but I follow the docs and all works good in console.
So, I have:
class AbstractModel < ActiveRecord::Base
self.abstract_class = true
has_many :configs, as: :configurable
end
class Config < AbstractModel
belongs_to :configurable, polymorphic: true
accepts_nested_attributes_for :configurable
end
All bu models inherit from AbstractModel
so, i have ability to use association with all my classes.
In ActiveAdmin I post:
ActiveAdmin.register Config do
permit_params :title, :internal_name, :configurable, :configurable_id, :configurable_type
filter :title
form builder: ActiveadminPolymorphic::FormBuilder do |f|
f.semantic_errors(*f.object.errors.keys)
f.inputs do
f.input :title
f.input :internal_name
SECTIONABLES = [PriceList, Hall]
f.polymorphic_has_many :configs, :configurable, types: SECTIONABLES
end
f.actions
end
end
trace log:
Completed 500 Internal Server Error in 1731ms (ActiveRecord: 13.0ms)
NoMethodError - undefined method `configurable' for nil:NilClass:
activeadmin_polymorphic (0.3.4) lib/activeadmin_polymorphic/form_builder.rb:105:in `block in polymorphic_form'
formtastic (3.1.4) lib/formtastic/helpers/inputs_helper.rb:376:in `block (2 levels) in inputs_for_nested_attributes'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:202:in `with_output_buffer'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (3.1.4) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
formtastic (3.1.4) lib/formtastic/helpers/inputs_helper.rb:293:in `inputs'
formtastic (3.1.4) lib/formtastic/helpers/inputs_helper.rb:374:in `block in inputs_for_nested_attributes'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:202:in `with_output_buffer'
actionview (4.2.6) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionview (4.2.6) lib/action_view/helpers/form_helper.rb:714:in `fields_for'
...
I can provide all other needed information and I'll be very pleased for your answer.
They've removed Iconic from ActiveAdmin (activeadmin/activeadmin#3553), which breaks our stuff. We should probabaly remove it too.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.