Question: How can i create a custom filter to replace:

```
<a href="http://www.externalsite.com">Whatever text</a>

```

into this:

```
<a href="#" ng-click="openExternal('http://www.externalsite.com')">Whatever text</a>

```

it should be easy, but i'm unable to do it… I have this:

```
<div ng-bind-html="item.htmltext | myFilter"></div>

```

and item.htmltext contains some tags that i want to replace that way… How should i create myFilter to replace the links?

Answer: 
**UPDATE**: Use Ruby 2.1.2, it fixes this issue.

---

14.04 is probably shipping with readline 6.3, which uses `rl_hook_func_t` instead of `Function`.

This bug has already been reported and fixed in Ruby (<https://bugs.ruby-lang.org/issues/9578>), but not released yet.

Until Ruby 2.1.2 comes out (which I assume will contain this fix), you can use a [patch](https://gist.github.com/mislav/a18b9d7f0dc5b9efc162) to properly support the new `rl_hook_func_t` method. Use this to install Ruby 2.1.1:

```
curl -fsSL https://gist.github.com/mislav/a18b9d7f0dc5b9efc162.txt | rbenv install --patch 2.1.1

```

(Source: <http://gorails.com/setup/ubuntu/14.04>)
**UPDATE**: Ruby 2.1.2, fixes this issue. If you need to patch ruby with Chef for another reason follow the example here.

---

Chef installation of Ruby 2.1.1 on to Ubuntu 14.04 using [LWRP](http://docs.opscode.com/lwrp.html)
--------------------------------------------------------------------------------------------------

Code to patch Ruby 2.1.1 on Trusty Ubuntu (14.04) using [Riotgames rbenv cookbook](https://github.com/RiotGames/rbenv-cookbook) - cut and pasted - no warranty :-) [I have a wrapper cookbook which is tested on Ubuntu 14.04 (release 1.0.4)](https://github.com/BCS-io/bcs_rbenv). Easiest way is get this going is to clone the repository and converge it on test kitchen. The main gotcha is that the cookbook uses Berkshelf 3.1.1 and most people are probably on 2 still. The pasted code should work on Berkshelf 2.x and 3.1.1.

*Berksfile*

```
cookbook 'rbenv', github: "RiotGames/rbenv-cookbook"

```

*Metadata*

```
depends 'rbenv'

```

*Attributes (attributes/default.rb)*

```
default['ruby']['version'] = '2.1.1'

```

*Recipe (recipes/default.rb)*

```
# patchutils is required to patch Ruby version
package 'patchutils'

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

# Installs a patched, global, ruby 
rbenv_ruby node['ruby']['version'] do
  global true
  patch "https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/45225/diff?format=diff"
end

```

[Discussion for patch](https://github.com/RiotGames/rbenv-cookbook/pull/97)

Rich