Skip to content

Commit

Permalink
improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiobayona committed Feb 21, 2024
1 parent d6773cb commit 70f0e36
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ class User < ApplicationRecord
model_description "A user of the system"
property :name, description: "The user's name", title: "Full Name"
property :group, enum: [1, 2, 3], default: 1, description: "The user's group"
virtual_property :age, type: "integer", description: "The user's age"
end
end
```

In the example above, the `enhance_schema` method is used to add a description to the model, change the title of the `name` property and add a description. It adds an enum, default value and a description to the `group` property.

Use the `property` keyword for the existing model attributes. In other words the symbol passed to the `property` method must be a column in the table that the model represents. Property does not accept a `type` argument, as the type is inferred from the column type.

Use the `virtual_property` keyword for properties that are not columns in the table that the model represents.Virtual properties do accept a `type` argument, as the type cannot be inferred from the column type.


## Development

Expand Down

0 comments on commit 70f0e36

Please sign in to comment.