This is a complete memorandum. .. .. It's unsightly, but let me post it once. I will fix it later.
user.rb
has_many :hoges
has_many :hoge_events
hoge.rb
belongs_to :user
has_many :hoge_events
hoge_events.rb
belongs_to :user
belongs_to :hoge
The screen (view) has the following links.
①hoge_event ②hoge_event ③hoge_event ④hoge_event
For example, when the user who is currently operating clicks the event details of ③, all the information about ③ is displayed. If you click the event details of ①, you want to display all the information about ①. (It is assumed that params are also passed firmly)
def show
@hoge_events = current_user.hoge_events.where(hoge_id: params[:hoge_id])
end
I was able to display the details for each event on the screen.
Recommended Posts