MCS
MCS

Reputation: 22541

Is Rails appropriate for use with a non-web-centric app?

It seems to me that Rails shines when building web-centric applications such as the Depot online-store app presented in the Agile book or the Basecamp project management system. The crux of these applications is their web interface, and Rails gives you the tools to create these webapps quickly, easily, and elegantly.

But what if you have an application with a command line interface for which you'd like to add a front-end? For example, imagine an application which processes third-party EDI files - it gets them from an FTP server, parses them, inserts the data into a database and sends out reports via emails. The schedule of when the app should run, which reports should be generated, who should get the email, etc. is all configured in a database. And although the main point of the application is the processing of EDI files and you want to run it via cron, you'd like to build a web page to allow users to manage which reports they're receiving, how often they receive them, etc.

Both the command line app and the web page need to access the same data in the database. They should be able to share models and business logic. If the command line app already contains a library with a data access layer, is there a way to leverage this library within Rails? Or, conversely, is there a way to reuse Rails' models and controllers in an outside app? Or does it not make sense to use Rails as the web framework in this scenario?

Upvotes: 1

Views: 227

Answers (2)

kikito
kikito

Reputation: 52641

Actually, most rails apps have a web interface and also a command-line interface - through rake.

The classical example are batch jobs that have to be run periodically, though cron or whenever. But it is also possible to run those tasks manually.

If I were you, I'd try building some rake tasks inside lib/tasks in order to map those command-line commands.

Upvotes: 2

jasonpgignac
jasonpgignac

Reputation: 2306

You could always just include the ActiveRecord library (and ActiveSupport) in a regular ruby application, if you are just looking to abstract away the model layer for a db centric app.

Upvotes: 4

Related Questions