tonyhokan / belt_reviewer Goto Github PK
View Code? Open in Web Editor NEWan g exercise about rails
an g exercise about rails
On line 3, event_id
assignment is unnecessary.
@comment.save
will not throw exception if the save failed, and we are not handling the error case here. If the record fails to save, it will fail silently without anyone noticing. Silent failure is generally bad.
Use @comment.save!
instead, or handle the error case manually.
Storing user_id in session and reading it directly has no security measures. It is acceptable in this practice but it is extremely dangerous for practical usage and is something to be aware of.
flash[:event]
is usually only used for storing string messages rather than objects. Was this practice shown in some guidelines that I'm not aware of?
There is a method called event_comments
which is responsible for creating a string to display to the user. That is view logic, so it should not live in the controller. It should live in the view erb instead.
In
:Prefer assigning local variable registration =
instead of instance variable @registration =
if it is not necessary.
Others:
I see that you have some validations in place for some models, and that is good. It is a good practice to also enforce data integrity at the database level. What I usually do is to apply the same validation in the rails model and the db column, but this is not required and can be a judgement call. Though it is usually a good idea to enforce data integrity at db level as I've said.
Also, none of the controllers are guarded by whether the user is authenticated. This means that all pages are accessible to anyone, which is not a desirable situation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.