我期待從陣列得到一個ID,當得到它顯示了這個行動上添加Order.newRails的預期,得到了陣列
顏色(#70131258622840)預期,得到了陣列(#70131401174240 )
有人有什麼想法爲什麼?
產品型號
has_many :colorships
has_many :colors, through: :colorships
顏色模型
has_many :colorships
has_many :products, :through => :colorships
產物控制器
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
顯示整個回溯有助於他人查看問題的存在位置,因此我鼓勵您顯示確切的錯誤。 – uday