I have some table in my DB like following: Post(id, title, content,
First question, what type ActiveRecord returns?
For example if i do something like: @posts = Post.all, through debugger
[#<Post id: 1, title: “My first post”, content: “Zdravo, ovo je moj
post.”, created_at: “2013-10-17 10:06:55”, updated_at: “2013-10-17
#<Post id: 3, title: “My second post”, content: “Zdravo, ovo je moj
post.”, created_at: “2013-10-17 11:11:29”, updated_at: “2013-10-17
#<Post id: 18, title: “My third post”, content: “Dobar dan, ovo je moj
treci post.”, created_at: “2013-10-18 11:31:07”,updated_at: “2013-10-18
So this is array of hashes? or array of Post objects?
Second if i do something like:
@post = Post.first (this will return Post object?)
then through debugger i can do: @post.id
Here, i’m guessing, because each model is inherit from
ActiveRecord will create accessor for each column in table that
Because that i can write something like @post.id or @post.id = 100.
So internally ActiveRecord does something like attr_accessor :id for
model? (and for every other column in posts table, attr_accesor: title,