lundi 14 novembre 2016

Rails how select a id on a array?

I have color has many products though colorships and products has many colors though colorships

on product controller i would like by select choose a color

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


def show
  Product.find(params[:id])
  current_user.find_by_color_id(product.color_ids.nil? ? nil : product.color_ids.color.id)
end

Aucun commentaire:

Enregistrer un commentaire