ruby on rails - Nested models work fine in development but are not being saved in production -
this first heroku deploy , i'm having odd issue can't seem figure out. app has nested form when create product
can add skus
. works great in dev, when deployed heroku
nested form rejecting skus
blank. i've added skus
individually (outside of product
form) , works fine, additionally there nested dimensions
fields in product
form save properly. seems nested skus
doesn't like.
oddly enough logs seem show there nested attributes present skus
when submit form.
the error when form gets kicked , says: skus can't blank
also, i'm not understanding why, in log files parameters
getting cut off, how it's displayed in heroku logs?
the other odd thing don't have validation skus
, far can tell product
should able saved if sku
blank.
any advice far troubleshooting or avenues investigate appreciated.
logs
2013-07-31t21:13:20.977351+00:00 app[web.1]: name: add image :: f.object: #<product:0x007fabc02a7bf0> :: association: images :: container: product-image :: name: add image :: f.object: #<dimension:0x007fabc1dcd6c8> :: association: image :: container: dimension-image-37265 :: name: add dimension :: f.object: #<product:0x007fabc02a7bf0> :: association: dimensions :: container: dimensions :: child_association: image :: name: add image :: f.object: #<dimension:0x007fabc2ea5838> :: association: image :: container: dimension-image-61466 :: name: add skus :: f.object: #<product:0x007fabc02a7bf0> :: association: skus :: container: skus :: child_association: images :: name: add images :: f.object: #<sku:0x007fabc305cde8> :: association: images :: container: sku-image-4581 :: processing productscontroller#create html 2013-07-31t21:13:20.977351+00:00 app[web.1]: che"=>"", "_destroy"=>"false"}}}}}, "commit"=>"save"} 2013-07-31t21:13:20.977351+00:00 app[web.1]: rendered components/_component_select.html.haml (5.5ms) 2013-07-31t21:13:20.977351+00:00 app[web.1]: rendered components/_component_select.html.haml (3.3ms) 2013-07-31t21:13:20.977351+00:00 app[web.1]: rendered components/_component_select.html.haml (2.5ms) 2013-07-31t21:13:20.977351+00:00 app[web.1]: parameters: {"utf8"=>"✓", "authenticity_token"=>"y7omgrfxdbre2zw63voqpp8j/w9syjfgcsphzhppjeq=", "product"=>{"active"=>"1", "shown"=>"1", "skin_id"=>"2", "collection_id"=>"1", "component_ids"=>["9"], "title"=>"test", "images_attributes"=>{"0"=>{"asset_cache"=>"", "_destroy"=>"false"}}, "features"=>"<p>test</p>\r\n", "dimensions_attributes"=>{"0"=>{"_destroy"=>"false", "title"=>"overall dimensions", "width"=>"1", "height"=>"1", "depth"=>"1", "image_attributes"=>{"0"=>{"asset_cache"=>"", "_destroy"=>"false"}}}}, "video"=>"", "skus_attributes"=>{"0"=>{"_destroy"=>"false", "finish_id"=>"1", "title"=>"lskdjf", "images_attributes"=>{"0"=>{"asset"=>#<actiondispatch::http::uploadedfile:0x007fabc014dcf0 @original_filename="albino stallion.jpg", @content_type="image/jpeg", @headers="content-disposition: form-data; name=\"product[skus_attributes][0][images_attributes][0][asset]\"; filename=\"albino stallion.jpg\"\r\ncontent-type: image/jpeg\r\n", @tempfile=#<tempfile:/tmp/rackmultipart20130731-2-1n97ibo>>, "asset_ca 2013-07-31t21:13:20.977351+00:00 app[web.1]: rendered components/_component_select.html.haml (3.1ms)
product.rb
class product < activerecord::base include rails.application.routes.url_helpers default_scope order('products.id asc') attr_accessible :name, :title, :features, :active, :shown, :video, ## belongs_to ## :collection_id, :skin_id, ## has_many ## :component_ids, ## nested attributes ## :skus_attributes, :dimensions_attributes, :images_attributes belongs_to :component belongs_to :collection belongs_to :skin has_many :product_compilation_components, :dependent => :destroy has_many :components, :through => :product_compilation_components has_many :dimensions, dependent: :destroy accepts_nested_attributes_for :dimensions, reject_if: lambda { |a| a[:width].blank? || a[:height].blank? || a[:depth].blank? }, allow_destroy: true has_many :skus, dependent: :destroy accepts_nested_attributes_for :skus has_many :images, as: :imageable, dependent: :destroy accepts_nested_attributes_for :images, reject_if: proc { |attrs| attrs['asset'].blank? && attrs['asset_cache'].blank? }, allow_destroy: true validates_presence_of :title validates_presence_of :collection validates_presence_of :skin before_save :create_name def show if self.active && self.shown return true end return false end def path(sku = skus.first) return product_sku_path(id, sku.id) end def categories @category_ids = collection.components.map{ |component| component.category_id } @categories = category.all(:conditions => { :id => @category_ids }) return @categories end def brands @brand_ids = collection.styles.map{|style| style.brand_id} @brands = brand.all(:conditions => { :id => @brand_ids }) return @brands end def self.skus_by_finish(finish_id) @skus = sku.where(:finish_id => finish_id); return @skus end private def create_name self.name = title.parameterize end end
so i'm not 100% sure problem i've fixed it. ended removing had skus adding in bit bit.
what think caused issue had version of product
class renamed because wasn't using , didn't want lose track of work had done (i know, not necessary i'm using git. guess old habits die hard) anyway, had changed file name, neglected rename class definition in file. name such came after real product
class using. i'm thinking caused conflict on heroku. thing don't understand why didn't cause problems in local dev environment.
Comments
Post a Comment