Controllers also coordinate with the presentation of the response. Again, the lines of responsibility can be a bit a fuzzy - does the logic go in the controller or in the .erb file?
Here is my sense for controllers:
- Functional Authorization
- Does the user have to be signed-in to access the controller's method?
- Is the user allowed to access the method? For example, is it superuser-only?
- Check for basic argument correctness
- Required parameters
- Extraneous parameters (e.g. white-list)
- Data Authorization
- Is the user allowed to see/modify/delete that particular data?
- Invocation of domain logic
- Error handling
- Assigning domain logic results to instance variables
- For use by result rendering (HTML, XML, JSON)
- Selection and invocation of the result rendering code
- Often done implicitly by Rails!
- Correct presentation of errors
No comments:
Post a Comment