Tim Uckun
2006-Jul-28 01:44 UTC
[Rails] Best practice for sharing code between rails apps.
Is there a writeup about how to structrure your rails applications so that you can share models, gems, libraries, helpers, and controllers between them. It would be especially helpful if the discussion involved how to structure your codebase in version control and how to manage deployement.
Benjamin Curtis
2006-Jul-28 01:58 UTC
[Rails] Best practice for sharing code between rails apps.
Well, just use subversion for all your apps, then use svn:externals to share pieces of them with each other. How''s that for a write-up? :) -- Benjamin Curtis http://www.bencurtis.com/ http://www.tesly.com/ -- Collaborative test case management http://www.agilewebdevelopment.com/ -- Resources for the Rails community On Jul 27, 2006, at 6:44 PM, Tim Uckun wrote:> Is there a writeup about how to structrure your rails applications so > that you can share models, gems, libraries, helpers, and controllers > between them. It would be especially helpful if the discussion > involved how to structure your codebase in version control and how to > manage deployement. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/525bef3b/attachment.html
Tim Uckun
2006-Jul-28 10:02 UTC
[Rails] Best practice for sharing code between rails apps.
> > Well, just use subversion for all your apps, then use svn:externals to share > pieces of them with each other. How''s that for a write-up? :)How would that work exactly? Let''s say I have a model, or a fragment I want to share amongst different ror apps. I presume I check these things into their own repos and then "attach" them to my application. Can I just specify one file or five files as an external or does it have to be an entire directory. If the latter how do I make sure ror sees them?
Benjamin Curtis
2006-Jul-28 13:17 UTC
[Rails] Best practice for sharing code between rails apps.
You can only specify directories as externals. So, how you can get at them depends on what you want to share. If it''s a set of models, you can attach them as a subdirectory of lib and require it from there. If it''s a set of views you can attach them to app/views. These methods are not as convenient as plugins or engines, though. In fact, this is the best use-case for engines -- sharing common functionality among a number of internal applications. Generally speaking, you''ll have an easier time of it if you can package up the functionality you want to share into a plugin or engine and then install the plugin/engine via svn externals. -- Benjamin Curtis http://www.bencurtis.com/ http://www.tesly.com/ -- Collaborative test case management http://www.agilewebdevelopment.com/ -- Resources for the Rails community On Jul 28, 2006, at 3:02 AM, Tim Uckun wrote:>> >> Well, just use subversion for all your apps, then use >> svn:externals to share >> pieces of them with each other. How''s that for a write-up? :) > > > How would that work exactly? Let''s say I have a model, or a fragment I > want to share amongst different ror apps. I presume I check these > things into their own repos and then "attach" them to my application. > Can I just specify one file or five files as an external or does it > have to be an entire directory. If the latter how do I make sure ror > sees them? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/602d9d37/attachment.html
Jeff Everett
2006-Jul-28 14:22 UTC
[Rails] Best practice for sharing code between rails apps.
We had a similar problem. So we put all our core business logic into a set of shared models, bindled them as a plugin, and distribute them that way between the applications that share them. This seems to be a little cleaner then svn:externals when you want to share some models but not all of them. There''s a discussion of this in Rails Recipes, if you can get a copy. But making a basic plugin is dead simple: ./script/generate plugin my_plugin_name will build the plugin structure in vendor/plugins. Then just dump all your models into the lib directory. Everything there will be included automagically by your app. HTH, Jeff On 7/28/06, Benjamin Curtis <rails@bencurtis.com> wrote:> > You can only specify directories as externals. So, how you can get at > them depends on what you want to share. If it''s a set of models, you can > attach them as a subdirectory of lib and require it from there. If it''s a > set of views you can attach them to app/views. > These methods are not as convenient as plugins or engines, though. In > fact, this is the best use-case for engines -- sharing common functionality > among a number of internal applications. Generally speaking, you''ll have an > easier time of it if you can package up the functionality you want to share > into a plugin or engine and then install the plugin/engine via svn > externals. > > > -- > Benjamin Curtis > http://www.bencurtis.com/ > http://www.tesly.com/ -- Collaborative test case management > http://www.agilewebdevelopment.com/ -- Resources for the Rails community > > > > On Jul 28, 2006, at 3:02 AM, Tim Uckun wrote: > > > Well, just use subversion for all your apps, then use svn:externals to > share > pieces of them with each other. How''s that for a write-up? :) > > > > How would that work exactly? Let''s say I have a model, or a fragment I > want to share amongst different ror apps. I presume I check these > things into their own repos and then "attach" them to my application. > Can I just specify one file or five files as an external or does it > have to be an entire directory. If the latter how do I make sure ror > sees them? > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060728/684b934e/attachment.html
Tim Uckun
2006-Jul-29 01:58 UTC
[Rails] Best practice for sharing code between rails apps.
> > will build the plugin structure in vendor/plugins. Then just dump all your > models into the lib directory. Everything there will be included > automagically by your app.Thank you for the tip. I was under the impression that there would be some performance problems with plugins but I will try it out and see for myself. I thought of one other way which is to use REST or Web services. Run one rails app that contains the shared functionality and interact with it via web services from your other rails apps. That might be slower still but it would certainly work and it would keep things pretty well separated. Is there a message que or some sort of a corba like interop service for ruby? Hopefully one that''s much simpler.