CSC/ECE 517 Fall 2023 - E2369. Reimplement duties controller.rb and badges controller.rb

From Expertiza_Wiki
Revision as of 00:11, 31 October 2023 by Avarma4 (talk | contribs)
Jump to navigation Jump to search

Topic Overview & Prior Work

Background

duties_controller.rb

The actions defined by this duties_controller include create, update, and remove. The new duty is saved to the database using the create action. The update action is used to update the duty in the database, while the edit action renders the form for editing an existing duty. Lastly, a duty can be removed from the database by using the delete action. All things considered, Expertiza's Duties module aids in the management of duties.

badges_controller.rb

A new Badge instance is created by the controller using the user-supplied parameters through the use of the create action. If an image file is attached, it additionally saves it and modifies the badge instance's image_name attribute.

Previous Work

The prior implementation of the duties and badges controllers was based on a Rails MVC application rather than strictly as an API built on Rails. The handling of requests and responses did not align with the API architecture, thus needing adjustments to ensure a more suitable API-style communication. Furthermore, the previous implementation lacked comprehensive testing, a crucial aspect that needs attention in the reimplementation.

Planned Work

Functions to implement

Functionalities for Duties

  • Create Action: Implement the functionality to add and persist new duties to the database.
  • Edit Action: Develop the mechanism to modify existing duties, providing a form for editing duties.
  • Update Action: Enhance the capability to update existing duties already stored in the database.

Functionalities for Badges

  • Create Action: Implement the creation process for new badges, utilizing user-provided parameters.
  • Image Handling: Develop a mechanism to handle attached image files, ensuring their storage.
  • Update Action: Enhance the functionality to update the image_name attribute associated with a badge instance, especially when an image is attached.

Notes for Reimplementation

  • Ensure that all interactions with the controllers adhere to API conventions, returning data in JSON format.
  • Thoroughly test all REST endpoints for both duties and badges, covering various scenarios to validate their functionality. Comprehensive testing should encompass both success and failure scenarios.