CSC/ECE 517 Spring 2019 - E1919 CodeClimate Issues
CSC/ECE 517 Spring 2019 / E1919. Fix Code Climate issues in models with names beginning with ‘H’ thru ‘Sc
This wiki page is for the description of changes made according to the specification of E1919, OSS project.
About Expertiza
Expertiza is a platform where assignments and related quizzes are managed. On this portal instructor upload assignments/questionnaires, create list of topics for students and edit the existing assignments. Students can form teams, work on projects and submit their assignments as URL or files. It also helps in improving the work quality by allowing students to provide anonymous reviews. It is an Open source platform which is based on Ruby with Rails.
Problem Statement
There were code smells detected in the application by code climate which violated the best practices of Ruby Rails. The goal was to fix those code smells by refactoring. e.g. 1. belongs_to :topic, class_name: 'SignUpTopic'.
In the class 'SignUpTopic', we have has_many :teams
When you have two models in a has_many, has_one or belongs_to association, the :inverse_of option in Rails tells ActiveRecord that they're two sides of the same association. Knowing the other side of the same association Rails can optimize object loading and will reference the same object in memory, instead of loading another copy of the same record.
2. in the file roles.rb we have has_many :users
We need to specify "dependent" option here.