R
R
Roman Dmitriev2020-02-03 11:27:53
Ruby on Rails
Roman Dmitriev, 2020-02-03 11:27:53

How to properly edit Ruby code?

Dear colleagues.

Faced with the need to make changes to the site. With Ruby and others like them - I had no luck to face. Before that, most of the sites were made on Wordpress / PHP, with which, in principle, at the required level for improvements, everything is obvious.
Please suggest what and how to fix, and at the same time point to good manuals / textbooks on the topic. And then the site ( https://parts.maz.ru/ ) will need to be picked regularly.

Actually here is the code:

<div class="b-phone">
<%= current_region.contact.phone.to_s.split(',').map{|phone| content_tag(:a, :href => "tel:+#{phone.to_s.gsub(/[^\d]/, '')}"){
first_phone = phone.split(')').first + ")"
last_phone = phone.split(')').last
content_tag(:span){first_phone} + last_phone
}}.join('<br>').html_safe -%>
</div>


Gives out this:

<div class="b-phone">
<a href="tel:+7495924151579859241515"><span>+7 (495)</span> 924-15-15</a> </div>
<div class="b-order-call">
<a class="popup-overlay" rel="#contact-form" href="">Заказать звонок</a>
</div>


And I need to remove the duplicate number in the link like this:

<div class="b-phone">
<a href="tel:+74959241515"><span>+7 (495)</span> 924-15-15</a> </div>
<div class="b-order-call">
<a class="popup-overlay" rel="#contact-form" href="">Заказать звонок</a>
</div>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question