API to get a list of events to participate in Rails

Asked 2 years ago, Updated 2 years ago, 42 views

I would like to create an API for displaying a list of events that a particular user participates in on the user information screen in an application that has the following function of Rails.
I think the list of events created by the user can be obtained by current_user.events.all, but what method should I use to obtain the list of events that a particular user participates in?
Also, I would appreciate it if you could let me know if there are any best practices for creating an event management app with a follow-up function!

User has_many: events (user as event creator)
Event has_many:users,through::participations
Model definitions are as shown in .

ruby-on-rails api

2022-09-30 15:33

1 Answers

Depending on how information such as event participation is stored in the DB, your answers will vary, but
If the User model has that information, why don't we get the records of the target user, such as User.find?


2022-09-30 15:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.