-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor: Use current_conference
instead of set_conference
and conference
(1/3)
#2303
base: main
Are you sure you want to change the base?
Commits on May 5, 2024
-
Avoid overriding
set_speaker
method in SpeakerDashboardsControllerApplicationController has `set_speaker` method. ```ruby def set_speaker if current_user @speaker = Speaker.find_by(email: current_user[:info][:email], conference_id: set_conference.id) end end ``` SpeakerDashboardsController's method is ```ruby def set_speaker @conference ||= Conference.find_by(abbr: params[:event]) if current_user @speaker = Speaker.find_by(conference_id: @conference.id, email: current_user[:info][:email]) @talks = @speaker ? @speaker.talks.not_sponsor : [] end end ``` Only differences are related to setting @talks, so setting of `@talks` into the action. Note: `set_conference` implementation is here. https://github.com/cloudnativedaysjp/dreamkast/blob/6c4b9071bf895dea2f8006184382ed39e1ef885a/app/controllers/application_controller.rb#L128-L130 https://github.com/cloudnativedaysjp/dreamkast/blob/6c4b9071bf895dea2f8006184382ed39e1ef885a/app/controllers/application_controller.rb#L39-L41 ```ruby def set_conference @conference ||= Conference.find_by(abbr: event_name) end def event_name params[:event] end ```
Configuration menu - View commit details
-
Copy full SHA for 85dc770 - Browse repository at this point
Copy the full SHA 85dc770View commit details -
Avoid using return value of
set_conference
Use ivar `@conference` which is set by `set_conference` instead of `set_conference`'s return value.
Configuration menu - View commit details
-
Copy full SHA for 5e4876a - Browse repository at this point
Copy the full SHA 5e4876aView commit details -
Invoke
set_conference
via before_action in Secured, SecuredAdmin co……ncerns `set_conference` is now invoked automatically via `before_action` in the `Secured` and `SecuredAdmin` concerns. This change removes the need for explicit calls to `set_conference` in individual controller actions.
Configuration menu - View commit details
-
Copy full SHA for 01e8a69 - Browse repository at this point
Copy the full SHA 01e8a69View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea1f453 - Browse repository at this point
Copy the full SHA ea1f453View commit details -
Use @conference ivar directly in Secured and SecuredAdmin
Since `Secured` and `SecuredAdmin` modules already include the `set_conference` method as a `before_action`, the ivar `@conference` is consistently available. Remove redundant method calls to `conference`.
Configuration menu - View commit details
-
Copy full SHA for ec52c1b - Browse repository at this point
Copy the full SHA ec52c1bView commit details -
Ensure
set_conference
is called beforeset_profile
Enforce the calling `set_conference` before `set_profile` across controllers to access `@conference` ivar. `Secure` or `SecureAdmin` concerns already called `set_conference` by `before_action`. For api/v1 routes, explicitly call `set_conference` in each controller.
Configuration menu - View commit details
-
Copy full SHA for 5f44693 - Browse repository at this point
Copy the full SHA 5f44693View commit details -
Configuration menu - View commit details
-
Copy full SHA for e0cfd64 - Browse repository at this point
Copy the full SHA e0cfd64View commit details