lundi 14 novembre 2016

Rails expected, got Array

I'm looking to get a id from a array and when get it shows this on the action add Order.new

Color(#70131258622840) expected, got Array(#70131401174240)

someone have any idea why?

product model

has_many :colorships
  has_many :colors, through: :colorships

color model

  has_many :colorships
  has_many :products, :through => :colorships

product controller

def new
  Product.New
  @dropdown = @product.colors.collect { |co| [co.name, co.id] } 
end


def show
  Product.find(params[:id])
 color = product.colors.select { |i| [i.id] } 

end




def add
    product = Product.find(params[:id])
    if product
        color = product.colors.select { |i| [i.id] } 

        if order.nil? # create new order
          order = Order.new
          order.product = product
          order.color =   color        
end
end
end

Aucun commentaire:

Enregistrer un commentaire