Take the 2-minute tour ×

Is there anyone who can help me by defining the exact difference between Active Model, Active Record and Active Resource. I have done enough googling in order to find the exact difference, but didn't get anything concrete which can tell the exact difference between them. Right now they all look same to me. So please give me the appropriate answer with some concrete points.

share|improve this question

3 Answers 3

up vote 25 down vote accepted

Rails 3 is designed with modularity in mind. Each module has its own purpose and functionality.

ActiveModel: This component was created in Rails 3. They took all the model related parts that did not have a database requirement of Rails 2 ActiveRecord and moved it into ActiveModel. So ActiveModel includes things like validations. More information: http://www.rubyinside.com/rails-3-0s-activemodel-how-to-give-ruby-classes-some-activerecord-magic-2937.html

ActiveRecord: This is the component that associates a class to the database. This will give the class functionality such as methods that make it easy to pull records from the database (An example is the find method).

ActiveResource: Similar to ActiveRecord. However, instead of being backed by a database, an ActiveResource object is backed by another application through a web service API. More information: http://ofps.oreilly.com/titles/9780596521424/activeresource_id59243.html

(Couldn't figure out about ActiveBase... where did you hear it from?)

share|improve this answer
Thanks richardaday for such clear cut answer. Sorry for the wrong word "ActiveBase"..its "ActiveRecord::Base". Can you just tell me what this is? I know that Active record inherits from it but what is the actual use of "ActiveRecord::Base". Please tell me also also send me the link for detail answer if possible. –  Arif Usman Oct 9 '12 at 11:37
ActiveRecord::Base is ActiveRecord. I think you may be confused with the syntax ActiveRecord::Base: ActiveRecord is the module grouping together multiple classes that implement it's functionality (an example class would be Base). ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html and api.rubyonrails.org/classes/ActiveRecord/Base.html –  richardaday Oct 10 '12 at 7:57
If I answered your question please mark it as accepted. –  richardaday Oct 14 '12 at 19:33

What I understand:

ActiveModel + Database Support = ActiveRecord

ActiveModel via WebService API = AcitveResource

share|improve this answer

ActiveRecord https://github.com/rails/rails/tree/master/activerecord

Think record as in table record.

Sets up a mapping between a new class and an existing table in a database. In the context of an application, these classes are commonly referred to as models. Models can also be connected to other models; this is done by defining associations.

  class Firm < ActiveRecord::Base
    has_many   :clients
    has_one    :account
    belongs_to :conglomerate

ActiveResource https://github.com/rails/activeresource

Think resource as in resource routing.

Maps classes to REST (JSON or XML) resources similar to the way Active Record maps model classes to database tables.

  class Person < ActiveResource::Base
    # supply a restful API
    self.site = "http://api.people.com:3000"
  # Find a person with id = 1 from http://api.people.com:3000
  tyler = Person.find(1) 
  p tyler.favorite_page => 'stackoverflow'


  GET    => Person.find(1)
  POST   => Person.new(:name => 'Tyler', :favorite_page => 'stackoverflow') 
  PUT    => tyler.save
  DELETE => tyler.destroy

ActiveModel https://github.com/rails/rails/tree/master/activemodel

A module that can be used for many many things to help with your models and db interactions. Mostly recognized for adding validation support to models.

share|improve this answer

Your Answer


