Step 1: Create the Model and Database Migration
To create a new model and database migration file, run the following command:app/models/spree/brand.rb- the model filedb/migrate/XXXXXXXXXXXXXX_create_spree_brands.rb- the database migration file
spree_brands with the column name in the database. The name column is indexed for faster lookups. Also the model file app/models/spree/brand.rb is created.
Step 2: Extend the Model file
Now that the model file is created, let’s add some additional functionality to it, starting with validations:app/models/spree/brand.rb
- Inherits from
Spree::Baseto automatically inherit all Spree functionality. Also the model itself is namespaced underSpree::module, so it’s available asSpree::Brandin the application. validates :name, presence: true- using ActiveRecord validations to ensure that the name is present.

