How to package a sub application in a gem

Hi guys,

I am rather new to the rails world and need your help in pointing me to a good sample project and/or some hints how best to implement it.

I have implemented an API section for a website of mine that deals with API Key management and want to publish parts of it as a gem so that it can be easily used it in other projects. This consists of controllers, views, some mongoid models, some coffeescript code, some scss. In a way it is a mini application with replaceable parts.

What is the recommended way in Rails 3 to implement this in a gem so that it is reusable and future proof (Rails 3.1 comes to mind). Should I look into rails engines? Do you know of any samples that implement best practices?

Thanks

Martin

Hi guys,

I am rather new to the rails world and need your help in pointing me to a good sample project and/or some hints how best to implement it.

I have implemented an API section for a website of mine that deals with API Key management and want to publish parts of it as a gem so that it can be easily used it in other projects. This consists of controllers, views, some mongoid models, some coffeescript code, some scss. In a way it is a mini application with replaceable parts.

What is the recommended way in Rails 3 to implement this in a gem so that it is reusable and future proof (Rails 3.1 comes to mind). Should I look into rails engines? Do you know of any samples that implement best practices?

I just worked on a project which makes use of an engine. Although I did not create it I went through a decent amount of work to get it to play nice with the main app. It sounds to me that an engine would be the right thing as it handles including controllers, views, models, etc. If you google for rails engine I see that there are a number of results including a railscast which would be where I would start.

Thanks a lot. I really needed some assurance that this is the right direction.

Thanks a lot. I really needed some assurance that this is the right direction.

Sure, post back if you have any issues. One thing which I had some trouble with was that by default your principal application will load before the engine. This is a problem if you have, say, a model in your engine which you are intending to extend in your primary app and not the other way around. There is a way around this but just be aware.