I have a erb
file where in I want to access ruby object and attach it inside a string dynamically. Here is the code snippet I have. Ideally, I want to access the ruby object and then parse it. But, it dosent work as expected. Below, @ruby_object
is some kind of URL based on different env.
<div>
Visit this <a href="<%="google.com"%>">@ruby_object.sub('http', '')}"</a>.
</div>
Actually this did the trick for me.
<div>
Visit this <a href="<%="google.com"%>"><%=@ruby_object.dup.sub!(/https?(\:)?(\/)?(\/)?/, '') %></a>`.
</div>