A
A
azstel2016-12-31 10:40:24
Ruby on Rails
azstel, 2016-12-31 10:40:24

How to correctly write the code so that an image with a link to another page is displayed?

The site of auto parts, built on ruby, in the user's personal account all pictures are correctly displayed to go to another page, except for one. Instead of a picture, an empty block. After analyzing the page code, I came to the conclusion that the output code itself was not written correctly:

(order_item.actual? ? (SiteConfig.first.need_demand_bill?(order_item) ? link_to(image_tag('create_bill.png', :width => 16), actual_account_order_path(order_item.order)) : '') : ''),

These are displayed correctly:
(link_to('', new_customer_order_item_dialog_path(customer_id: order_item.customer_id, order_item_id: order_item.id),
                                             class: 'create-dialog',
                                             data: { id: order_item.id }, target: "_blank")),

(link_to(image_tag('order-history-icon.png', :width => '16'),
                                         customer_order_item_order_status_logs_url(current_customer, order_item),
                                         :data => { :fancybox_ajax => true },
                                         class: 'fancybox')),

(link_to('', 
                                         customer_order_item_url(current_customer, order_item), 
                                         :method => :delete, 
                                         :confirm => 'Вы уверены, что хотите отменить заказ?', 
                                         :class   => 'delete') if order_item.processing?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Bordenyuk, 2016-12-31
@HighQuality

First, the code should be made simpler, and the problem will be solved faster there.
Ternary operator in ternary operator? Let's better helper. :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question