Ruby on Rails
1
Вклад в тег
=form_for @line_item, url: create_line_item_path, html: {method: 'post'} do |f|
=f.hidden_field :product_id, value: @product.id
=@product.title
br
=f.collection_select(:size_id, @product.sizes.all, :id, :name)
=f.submit 'В корзину'
get 'line_items', to: 'line_items#create', via: 'post' , as: 'create_line_item'
def show_product_to_customer #товар, показываемый пользователю
@product = Product.find(params[:id])
@line_item =LineItem.new
end
def create
@cart = current_cart
size = Size.find(params[:line_item][:size_id])
product = Product.find(params[:line_item][:product_id])
@line_item = @cart.add_product(product.id, size.id)