Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Rails without a database at all and only calling web services?

I am planning to write some new UI code and many people suggested to use RoR. But from what I have read about RoR so far, it seems to be almost mandatory to have a database to store the backend data. In my case, I do not have access to a database and all my data objects are available through web services (some REST and SOAP services).

I think I have to use the controller to directly talk to the services in this case, but is it still a good idea to use RoR without the model layer (ActiveRecord).

Are there any other frameworks more suited for this kind of approach (I can use anything in Java or Ruby, we do not have any PHP or Python code).

like image 492
Arvind Avatar asked Jun 22 '09 05:06

Arvind


People also ask

Does rails need a database?

Just about every Rails application will interact with a database. The database to use is specified in a configuration file, config/database. yml. If you open this file in a new Rails application, you'll see a default database configuration using SQLite.


1 Answers

Rails will work just fine for this; it explicitly supports running without ActiveRecord. See the comment in the default environment.rb file:

# Skip frameworks you're not going to use. To use Rails without a database
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

Your database.yml file will be ignored if you don't load ActiveRecord; all of your models can inherit from ActiveResource::Base and will work just fine.

like image 186
Jim Puls Avatar answered Oct 06 '22 00:10

Jim Puls