1

I'm working on a project which involves aggregating data from a variety of sources so that users can search and mine it from a single front-end interface. The project breaks pretty cleanly into two components:

  1. The cron triggered (Whenever gem) code that pulls data from various sources and POPULATES the database.
  2. The front-end code that CONSUMES the data and presents it to the user.

I want to split the codebase into separate projects with a shared model to encourage clean separation of concerns but am not sure how best to go about that in Rails 3.

I saw this SO question about using a shared folder/submodule in SVN or Git but that doesn't seem very clean to me: Sharing Models between two Rails Projects - using git submodules?

I come from a Java/MVN background were you would just create 3 modules (one shared and two that depend on it) and call it a day. Then with Maven you could invoke a build on the parent project and it would automatically update the shared code JAR in each dependent project.

Can the same be achieved using Rails Engines, Rake, and RubyGems? Or is there a better "rails way" to do it?

Thanks,

-James

Community
  • 1
  • 1
jshkol
  • 1,777
  • 14
  • 19
  • There's 2 part to this question I need guidance on. Part 1 is how best to segment the model code from the 2 dependent apps into a Shared Gem; part 2 is how to use Rake/Rubygems to update the dependent projects with the latest Shared Gem whenever the shared code changes (ala Maven in the Java world). – jshkol Nov 09 '11 at 20:14

1 Answers1

0

You can keep the models in a gem/plugin. The DB configurations should remain in their respective apps, though.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
  • In this scenario do I keep the migrations with the model classes in the shared gem? If so when I run db:migrate on the dependent project will it pickup and run new migrations from the shared gem (using the dependent project's DB configuration)? – jshkol Nov 09 '11 at 20:09
  • This combined with pointing the Gemfile in the dependent projects directly at our Git repository for the shared project worked for me. – jshkol Feb 22 '12 at 01:50