ruby on rails 3 - polymorphic association with formtastic and mongo -
i'm trying create relationship between 2 models in rails.
i have product , offer offer belongs product.
class product include mongoid::document include mongoid::timestamps has_many :offers, as: :trigger_product, :class_name => "offer" end class offer include mongoid::document include mongoid::timestamps belongs_to :trigger_product, polymorphic: true accepts_nested_attributes_for :images, :product end
in formtastic, field trigger product added so
<%= f.input :trigger_product, :as=> :select, :multiple => false, :collection => @offer.trigger_products_list %>
when submit form, error
nameerror in admin::offerscontroller#create uninitialized constant triggerproduct app/controllers/admin/offers_controller.rb:7:in `create'
it appears me polymorphic association isn't working, don't think should need create empty model hold triggerproduct, error leads me believe issue.
any suggestions here?
turns out had relationship needing know of product_type value, product parent of many product types.
no way here @ have gotten , rails error didn't point in right direction.
if knows how might have debugged maybe way output required fields relationship expecting, i'll give points.
Comments
Post a Comment