What is the difference between attribute and column?

The two terms "attribute" and "column" seem to be used interchangeably ... but I assume that the column is a field and the attribute is what is included in the field.

+4
source share
2 answers

A “column” is a column in a database table, while “attribute (s)” are the external visible edges of an object.

The “attribute” is for the model, and the “column” is for the table in the database.

Here is the diagram for the model:

create_table "retreats", force: :cascade do |t|
  t.string "title"
  t.string "tagline"
  t.datetime "created_at", null: false
  t.datetime "updated_at", null: false
end

Here "retreats" is a table in the database with the following columns: "title", "tagline", "created_at", "updated_at".

Retreat, "title", "tagline", "created_at" "updated_at". .

, - .

1:

Rails. .

vojic , .

+4

ActiveModel attributes API , . https://blog.metova.com/rails-5-attributes-api

ActiveRecord ActiveModel columns attributes, , , . http://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html

, Rails ActiveRecord , . ActiveModels, ( ), API , Rails ActiveRecord.

0

Source: https://habr.com/ru/post/1680950/


All Articles