Hello,
So I have a text area that displays a products description, in the products description I would like to be able to create links to other products through the product's id. Mainly because the url's will change from time to time and I would hate to have random broken links on my site. Anyways so far I have this in my helper.
module ProductsHelper def product_description(product) product.description.gsub(/<a='''>/, "<a href='test.com'>") end
and then in my view I have this;
<%= product_description(@product) %>
Now when editing the text area for the products description, I would like to do something like this;
This is a test <a=12345>Product x</a>
So I would like gsub to be able to get the product id which would be 12345 and then replace that product id with the product.permalink field that is associated with that product.id. as you can tell I am totally lost on where to even go from here. any help would be greatly appreciated. Thanks in advance.