Create plug from RoR application

Hello.

I have an application that rails intependientemente works. But now Have asked me to run as a plugin.

And I would like to know if anyone can help me. Because I do not know if it's a Work trivial or need to change a lot of code. And I have no clear Where to start ...

Thank you.