views:

37

answers:

2

I am new to Ruby on Rails and my questions are about the application design, based on Rails 3. There are many data on the internet on the creation of standard websites (such as blogs) on Rails, but my application requires more than just "post and read" and I am not sure how to implement that.

The idea:

  1. The model "Route" includes a number of airlines modules: "Ryanair", "easyJet", etc.
  2. The "Route.Update" method calls the "UpdateRoutes" on each airline module (for example, "Ryanair.UpdateRoutes", "easyJet.UpdateRoutes")
  3. It should work the same way with more models (such as "Flight.find") and more airlines ("Delta.FindFlights")

The questions:

  1. Where should I store all the modules? I don't see any app/modules folder in Rails.
  2. If my modules require gems, should I include them in the modules or in the models (where they are actually used)?
  3. I want to make my application scalable. For example, I want to add a new working airline (module) without changing any code in "Route", "Flight" or any other model. I imagine something like the method "IncludeAirlines" which would go through modules/airlines/name.rb, include every module and call the needed method of it (such as name.UpdateRoutes). Is there any better way to implement that in Ruby on Rails?
A: 

First you should read some basics about RoR. The app folder is intended to store views/modules/controllers for your application. If you need to work with gems take a deep look into bundler About your application design that makes me think that you didn't understand OOP design so i would suggest to solve the other steps and than think about the rest a second time. And very important start with Testing (Unit, Functional and integration tests).

khmarbaise
+1  A: 
  1. Generally, modules are stored in the /lib folder.
  2. If your module uses a gem, you will need to require the gem in the module (sometimes a require is not at all necessary).

Your 3rd question is not clear. Sorry about that. Not quite sure what you're trying to do.

Shreyas Satish