uoft-tapp / tapp

MIT License
9 stars 24 forks source link

[Backend] Refactoring to best practices #228

Closed tsimica closed 4 years ago

tsimica commented 4 years ago

As discussed with @reidka, the Rails codebase needs to be refactored to adhere to best Rails practices. Some of the work would include (but not limited to):

General

Rails Specific config/routes.rb

app/controllers/api/v1/applications_controller.rb

Controllers not mentioned fall into some issue mentioned above, or they are yet to be posted here.

app/mailers/action_mailer.rb

app/models/session.rb

tsimica commented 4 years ago

I had a look just now at https://github.com/uoft-tapp/tapp/pull/218/files. It's less idiomatic than master. I am not too what the intention was here.

siefkenj commented 4 years ago

Most of these items look good. Two comments: (a) we decided on 4 spaces over 2. This is a calculated deviation; (b) we decided that the API would aways return 200, unless there was an uncaught rails error. The returned JSON should include {status: "error", ...} if there was an error that was caught. (I'm not sure if this is what you were referring to, but how can this result in stale data?)

We are also deviating from traditional rails REST in a few key ways: we only use GET and POST, we always return JSON with status 200, and we have upsert instead of insert and update (the rule being if the ID is included, it is an update, otherwise an insert)

tsimica commented 4 years ago

Understood. Thanks for clarifying.

For the stale data part, consider the following:

siefkenj commented 4 years ago

I think we'll need to talk about this in person. There is something I am not understanding about this situation.

siefkenj commented 4 years ago

I assume this was handled by the rewrite.