Sorry, if it is noob-question, which was here for 100-times. I have a list of articles, on which is button 'to cart'. I read a lot about modal view and rails, but all of them are for link_to, how to do that, if i press on my button, it's show me a modal window with my shopping cart? Here is part of my code, with button (it is free of form_tag etc, it is in:
- @articles.each do |art|
= button_to 'В корзину', line_items_path(ART_ID: art), :id => "to-cart"
I want, that if i click on it, controller method do what in do, but it doesn't redirect anywhere, i still must be on the same page, and modal view (using html and jquery) must appear with my shopping cart partial:
-unless cart.line_items.empty?
%table.zebra
%tr
%th Наименование
%th Артикул
%th Производитель
%th Количество
%th Сумма
= render(cart.line_items)
%p
Общая сумма
= cart.total_price
%p
Наименований (количество):
= cart.total_count
= button_to 'Очистить корзину', cart, method: :delete, confirm: 'Вы уверены?'
-if current_user
= button_to "Оформить заказ", new_order_path, method: :get
-else
%p
Пожалуйста, для оформления заказа войдите в систему:
%a#cartlogin{:href => "#"} Логин
%p
Если у вас нет аккаунта, зарегистрируйтесь:
= link_to "Регистрация", new_user_path
-else
Увы, ваша корзина пуста