Sha256: e6570878ebc635eb9092d9cc6880c9b46b11176bf85052bd229ee9f001ae5fa3

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

# In this file, you model your application. Refer to the README or get inspired
# by the full-fledged example below (which you can generate right away).

# Define a model + generate views with CRUD actions
# Since this generates the first web UI with an index action, the products list
# will become the home page of the generated app
crud 'product' do |product|
  # The first attribute of each model is taken as a human identifier/label
  product.attr :title # Default type "string"

  # The order of attributes is respected when generating the form for that model
  product.attr :price, type: :money
  product.attr :mode, assignable_values: %w[public private]
  product.attr :provider, type: :url
  product.attr :import_data, type: :json

  # Reference other models just like you called them
  product.belongs_to 'user'
end

# Define a model
model 'user' do |user|
  user.attr :email # Type "email" derived from attribute name

  user.attr :name
  user.attr :last_visit, type: :datetime
  user.attr :locked, type: :flag, default: false
end

# Add a web user interface for the 'user' model
web_ui 'user' do |web_ui|
  # All CRUD actions: index, show, new, create, edit, update, destroy
  web_ui.crud

  # Custom action
  web_ui.action :lock, scope: :member, method: :post
end

# Have a main menu
navigation

# Add authentication
authenticate 'user', system_email: 'system@example.com'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
katapult-0.4.1 lib/generators/katapult/app_model/templates/lib/katapult/application_model.rb
katapult-0.4.0 lib/generators/katapult/app_model/templates/lib/katapult/application_model.rb