Simplify query to retrieve NotificationSetting on controllers

parent d11288be
class Groups::NotificationSettingsController < Groups::ApplicationController class Groups::NotificationSettingsController < Groups::ApplicationController
def update def update
notification_setting = group.notification_settings.where(user_id: current_user).find(params[:id]) notification_setting = group.notification_settings.find_by(user_id: current_user)
saved = notification_setting.update_attributes(notification_setting_params) saved = notification_setting.update_attributes(notification_setting_params)
render json: { saved: saved } render json: { saved: saved }
......
...@@ -8,7 +8,7 @@ class Projects::NotificationSettingsController < Projects::ApplicationController ...@@ -8,7 +8,7 @@ class Projects::NotificationSettingsController < Projects::ApplicationController
end end
def update def update
notification_setting = project.notification_settings.where(user_id: current_user).find(params[:id]) notification_setting = project.notification_settings.find_by(user_id: current_user)
saved = notification_setting.update_attributes(notification_setting_params) saved = notification_setting.update_attributes(notification_setting_params)
render json: { saved: saved } render json: { saved: saved }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment