Scaffold generator for creating Lasso Objects.
There is a command line interface (CLI), which allows you to run the scaffold generator, and view the help documentation.
The follow the steps below to create a new Lasso Module.
- Create an attributes YAML file. This is where you define all the attributes of your model. See the 1. Supplying Attribute data section below.
- Run the generate scaffold command. See the 2. Run the Generate Command section below.
- Move the generated files to your Lasso website. See the 3. Install Files section below.
- See the 4. Configure Object Loading section below.
Copy the data/_example_attributes.yml and rename it replacing _example with the name of your Lasso Module. For
example, if your module was called coupon, name the file coupon_attributes.yml.
The attribute data is a YAML file, and is formatted like the following example:
---
-
name: address
field: Address1
type: String
default:
usage: required
-
name: unit
field: Address2
type: String
default:
usage: optionalThis produces the following in the Ruby code:
@attributes = [
{
name: 'address',
field: 'Address1',
type: 'String',
default:
usage: 'required'
},
{
name: 'unit',
field: 'Address2',
type: 'String',
default:
usage: 'optional'
}
]nameis the name of your attribute. Example:store_number.fieldis the Lasso database field it maps to. Example: 'StoreNbr'.typeis the Lasso data type to treat the attribute as. Examples:string,integer, orboolean.usageidentifies how we use the attribute. It takes one of the following values:required,optional,hidden,internal, orvirtualrequired: accept input, in dboptional: accept input, in dbhidden: no input, in dbinternal: no input, no dbvirtual: accept input, no db
| Name | Allows Input | Persists to Database |
|---|---|---|
required |
yes | yes |
optional |
yes | yes |
hidden |
no | yes |
internal |
no | no |
virtual |
yes | no |
- First
cdto the root of this app. - Launch the app's Bash console. Enter the $
./bashcommand. This will open a bash prompt running in a Docker container. - Enter a command like
ruby ./generator.rb scaffold NAMEwhereNAMEis the non-plural version of the module name, use all lowercase characters and underscore case (i.e. snakecase) format.
This will generate all your files and place them inside the output folder. The code will be in a folder with the
plural version of the name you supplied to the generator command.
After you've generated your new Lasso Module, you will find it in the output folder in the root of this project. To
install it in a Lasso website you'll need to drag-and-drop the module folder form the output folder into the root of
the Lasso website. Add
Add file path for the two new Lasso custom type files to the /library/load_custom_tags_and_types.inc file. Similar to the Coupon
example below:
// Coupon
'/coupons/Types/coupon_type.inc',
'/coupons/Types/coupons_type.inc',
This will make your new Lasso custom types available on every page of the web site.