[RUBY] Example of params using where

This is a complete memorandum. .. .. It's unsightly, but let me post it once. I will fix it later.

association

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

View

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)

controller

  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

Example of params using where
Example of using vue.config.js
Example of using abstract class
[Kotlin] Example of processing using Enum
Example of using ArAutoValueConverter (field type conversion)
Example of using addition faster than using StringBuilder (Java)
Summary of using FragmentArgs
Summary of using DBFlow
Summary of using Butter Knife
Rate-Limiting using RateLimiter of Resilience4j
Enumeration of combination patterns using List
Development of Flink using DataStream API
Validation of log messages using mockito
Handling of time zones using Java
Implementation of validation using regular expressions
Application example of design pattern (No. 1)
Acquisition of location information using FusedLocationProviderClient
Summary of object-oriented programming using Java
[Java] Where did you try using java?
I tried using GoogleHttpClient of Java
[Ruby On Rails] How to search the contents of params using include?