Class: Admin::FavoriteThingsController::Controls
- Inherits:
-
Object
- Object
- Admin::FavoriteThingsController::Controls
- Defined in:
- lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb
Instance Method Summary collapse
- #display_schema(action:) ⇒ Object
- #form_schema(action:) ⇒ Object
- #model ⇒ Object
- #permitted_params(params, action:) ⇒ Object
- #scope(action:) ⇒ Object
- #title ⇒ Object
Instance Method Details
#display_schema(action:) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 26 def display_schema(action:) Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type| fields[:name] = type.dynamic(&:itself) fields[:member] = type.dynamic { |member| "#{member.name} (member ##{member.id})" } end end |
#form_schema(action:) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 33 def form_schema(action:) Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type| fields[:name] = type.generic("form_field_text") fields[:member_attributes] = type.belongs_to(:member) do fields[:name] = type.generic("form_field_text") fields[:rank] = type.generic("form_field_select", collection: Member.ranks.keys) fields[:position] = type.generic("form_field_text") fields[:ship_id] = type.generic( "form_field_select", collection: Ship.all.map { |s| ["#{s.name} (Ship ##{s.id})", s.id] }, ) end end end |
#model ⇒ Object
14 15 16 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 14 def model FavoriteThing end |
#permitted_params(params, action:) ⇒ Object
22 23 24 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 22 def permitted_params(params, action:) params.require(:favorite_thing).permit(:name, member_attributes: [:id, :name, :rank, :position, :ship_id]) end |
#scope(action:) ⇒ Object
18 19 20 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 18 def scope(action:) FavoriteThing.all end |
#title ⇒ Object
10 11 12 |
# File 'lib/super/test_support/copy_app_templates/controllers/favorite_things_controller.rb', line 10 def title FavoriteThing.name.pluralize end |