Plugataryov Yura
Plugataryov Yura

Reputation: 168

How does Active Record retrieve data from a database in Rails?

I've started to learn some Rails internals, and today I tried to find how Rails retrieves data from a specific database server.

If I ran a simple select query via an ActiveRecord model instance method, the ActiveRecord connection adapter generates this query as a SQL statement, and then I've got the data.

What kind of object in ActiveRecord is responsive for parsing data from the database server and wrap this data into an ActiveRecord object?

Where in the Rails codebase can I look for how this part works?

Upvotes: 1

Views: 1675

Answers (1)

Abram
Abram

Reputation: 41874

Please check out Railscast walkthrough on this topic:

http://railscasts.com/episodes/239-activerecord-relation-walkthrough?view=asciicast

Upvotes: 1

Related Questions