Hello, I'm trying to complete my app but I'm blocked in front of a relation.
I have 3 models: Video, Gallery and Content.
Every model is sharable and I'm using a polymorphic relation, so I create a content_share model. I want to manage my association with the content_share controller and with a shared view, but I lose the association.
I use video as example
class Video < ActiveRecord::Base include Sharable end
module Sharable extend ActiveSupport::Concern included do has_one :content_share, as: :sharable accepts_nested_attributes_for :content_share, reject_if: :all_blank end end
The association works fine.
Now I must create a content_share associated to my video vith a form.
In my video controller I have:
def share render 'admin/shared/content_share', locals: { shared: video } end
The problem is the form: when I use
= simple_form_for [:admin, shared.build_content_share] do |form| = form.input :text = form.input :text2
I pass as params text and tex2, but I lose every reference to my "video" and I cannot save in my controller the element.
If I use the nested form, I must use the video controller (and the content controller, and the gallery controller, etc)
How can I fix this?