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?

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9391c202a475922a265b5e38498eca46%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to