Hi
Sorry but It would be good for future if you look at
ruby regular expressions instead of asking for any solutions.
Here is regular expression for gsub
product.description =~ /href="(\d+)/
product.description.gsub($1, product.url)
My suggestion is that use *$PRODUCT_URL_<ID>* instead of link in
description
of product
and then use gsub to render link in view.
*product.description.gsub(/$PRODUCT_URL_<\d+>/, product.url )*
On Sat, Mar 13, 2010 at 12:56 AM, Dan Paul
<akadanpaul-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Sandip
---
www.funonrails.com
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.