Although both helpers from Middleman and Rails are called the same, they are actually not the same in code. Moreover, encode
parameter has been removed from Rails 4 and you now have to require a separate gem to use it.
I think, your best option will be to look at the code in that gem and reimplement it as a separate helper for your Middleman project.