Giter Club home page Giter Club logo

activeadmin_polymorphic's People

Contributors

jacob-andersson avatar nashby avatar sindrenm avatar toothfairy avatar unimatrixzxero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activeadmin_polymorphic's Issues

Make a more complete demo

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

Image Upload

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

Does not run on rails 4.2.6

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.