Hey Everyone, If anyone has any questions about this course, please let me know and I will answer ASAP. It doesn't matter if it's 1 year from now or 10 years. Also, to master Rails quickly. It is important to get a mentor. I offer this on Patreon patreon.com/user?u=89485299&Link&
Thank you for this video! It was interesting to look at new Rails 8 stuff and war with kamal (devs normally has such wars everyday and it is normal) :) For me it was simpler to deploy via railway app service. Please keep going with more Rails stuff.
Thank you for sharing this informative tutorial! Below are some suggestions and observations that might improve the code and its maintainability: 1) Post Model and user Attribute Consider using a belongs_to :user, foreign_key: :user_id relationship or a references type for the user column in the posts table. This clarifies the association and enforces referential integrity. 2) Missing dependent: :destroy The has_many :comments and has_many :likes associations in the Post model (and others) would benefit from dependent: :destroy. This way, when a post is deleted, its comments and likes are removed automatically, preventing orphaned records. 3) Hidden user_id Field in Forms Including a hidden user_id in forms can be unsafe and is generally unnecessary. Instead, create posts/likes/comments directly through the current user, for example: current_user.posts.create(post_params) This approach is safer and more expressive of the relationship.
Part 2) 4) Polymorphic Like Model If you plan to allow likes on multiple models (e.g., posts, comments), consider making Like polymorphic (belongs_to :likeable, polymorphic: true). This design is more flexible and can handle liking various record types without duplicating code. 5) Partial for Like Count Extract the HTML displaying the total number of likes into a separate partial. After each creation or deletion of a like, broadcast (or otherwise update) the new count. This keeps the main views cleaner and promotes reusability. 6) Consolidated Creation/Deletion of Likes Managing like creation and removal in a single model method-and thus a single controller action-can simplify the logic. For example, a toggle_like method in the model could handle both cases. 7) Use a Concern for Shared Logic If likes become polymorphic, you can move their logic into a Rails concern. The same pattern could apply to comments if you need to enable discussions on multiple resources. Hope these points help make the application more robust and secure. Thank you again for the valuable tutorial!
As much as I appreciate your efforts, I find the pace too quick for me and lacks explanation for why using the mentioned features so a noob like me finds himself watching trying to understand to end up without added value after an hour and a half 😢
Hey Everyone,
If anyone has any questions about this course, please let me know and I will answer ASAP. It doesn't matter if it's 1 year from now or 10 years.
Also, to master Rails quickly. It is important to get a mentor. I offer this on Patreon
patreon.com/user?u=89485299&Link&
дякую!
Чудовий урок
No problem. Happy it helped!
Приємно чути солов'їну мову! Вітаю ще одного розробника на Ruby on Rail з України.
Слава України! Ми обовʼязково переможемо!
Thank you so much for this video....i was thinking about learning ROR but struggled to find latest resources...
Excellent. I'm glad you're here
Thank you for this video! It was interesting to look at new Rails 8 stuff and war with kamal (devs normally has such wars everyday and it is normal) :) For me it was simpler to deploy via railway app service.
Please keep going with more Rails stuff.
Ok I will
Good content, thanks for sharing
Glad you enjoyed it
I think you should do a video about action cable and solid cable. There's barely anything about it that is up to date.
That’s a great idea. I will do it.
that the video i am waiting for
Perfect, if you have questions let me know. I will answer them.
Thank you for sharing this informative tutorial! Below are some suggestions and observations that might improve the code and its maintainability:
1) Post Model and user Attribute
Consider using a belongs_to :user, foreign_key: :user_id relationship or a references type for the user column in the posts table. This clarifies the association and enforces referential integrity.
2) Missing dependent: :destroy
The has_many :comments and has_many :likes associations in the Post model (and others) would benefit from dependent: :destroy. This way, when a post is deleted, its comments and likes are removed automatically, preventing orphaned records.
3) Hidden user_id Field in Forms
Including a hidden user_id in forms can be unsafe and is generally unnecessary. Instead, create posts/likes/comments directly through the current user, for example:
current_user.posts.create(post_params)
This approach is safer and more expressive of the relationship.
Thank you for your valuable comment. All great points.
Fantastico! Grazie my friend
Perfect. Thank you for watching!
Part 2)
4) Polymorphic Like Model
If you plan to allow likes on multiple models (e.g., posts, comments), consider making Like polymorphic (belongs_to :likeable, polymorphic: true). This design is more flexible and can handle liking various record types without duplicating code.
5) Partial for Like Count
Extract the HTML displaying the total number of likes into a separate partial. After each creation or deletion of a like, broadcast (or otherwise update) the new count. This keeps the main views cleaner and promotes reusability.
6) Consolidated Creation/Deletion of Likes
Managing like creation and removal in a single model method-and thus a single controller action-can simplify the logic. For example, a toggle_like method in the model could handle both cases.
7) Use a Concern for Shared Logic
If likes become polymorphic, you can move their logic into a Rails concern. The same pattern could apply to comments if you need to enable discussions on multiple resources.
Hope these points help make the application more robust and secure. Thank you again for the valuable tutorial!
Excellent comment
Hello can you make a video about rails api only?
Ok
@MalachiRails thank you so much !
As much as I appreciate your efforts, I find the pace too quick for me and lacks explanation for why using the mentioned features so a noob like me finds himself watching trying to understand to end up without added value after an hour and a half 😢
Thank you for that I will that into account
Can't we use a front-end library like react instead of the rails traditional views ?, can you make a tutorial related to that ?.
yeah you can...using Rails as just an API
The classic javascript developer overcomplicating everything that they don't need to.
Fr fr
@ But bro in these days alot companies are switching to react
@ Next friday ?
Thanks
But We need SaaS projects
Like loom, printify, linktree etc
I will see
Thanks for the content but you need to go so fast…
Noted