A friend of mine found himself in the situation of having to implement the same business logic in both Javascript and Ruby.<p>So he wondered how to get rid of that duplication. The solution he came up with is IncludeJS which allows you to implement something in Javascript and use that code _both_ in Javascript and in Ruby.<p>He gave a talk on this topic during RailsConf2011, which provides some more details:
http://en.oreilly.com/rails2011/public/schedule/detail/1941