diff --git a/Rakefile b/Rakefile
index 881d107723..1ef085c13b 100644
--- a/Rakefile
+++ b/Rakefile
@@ -25,30 +25,28 @@ end
desc 'Automate the Config Setup for New Environments'
task setup_workspace: :environment do
- begin
- SECRETS = {
- SECRET_KEY_BASE: generate_secret,
- DEVISE_SECRET_KEY: generate_secret
- }.freeze
-
- %w[development test].each do |environment|
- example = Rails.root.join('config', 'env', "#{environment}.example.env")
- target = Rails.root.join('config', 'env', "#{environment}.env")
- FileUtils.cp(example, target)
-
- # insert the secrets into the file
- content = File.read(target)
- %w[SECRET_KEY_BASE DEVISE_SECRET_KEY].each do |key|
- content.sub!(%(#{key}=""), %(#{key}="#{SECRETS[key.to_sym]}"))
- end
- File.write(target, content)
+ SECRETS = {
+ SECRET_KEY_BASE: generate_secret,
+ DEVISE_SECRET_KEY: generate_secret
+ }.freeze
+
+ %w[development test].each do |environment|
+ example = Rails.root.join('config', 'env', "#{environment}.example.env")
+ target = Rails.root.join('config', 'env', "#{environment}.env")
+ FileUtils.cp(example, target)
+
+ # insert the secrets into the file
+ content = File.read(target)
+ %w[SECRET_KEY_BASE DEVISE_SECRET_KEY].each do |key|
+ content.sub!(%(#{key}=""), %(#{key}="#{SECRETS[key.to_sym]}"))
end
-
- puts "Workspace setup completed successfully 🎉"
- rescue StandardError => e
- puts "Exception Occurred #{e.class}. Message: #{e.message}. Backtrace: \n #{e.backtrace.join("\n")}"
- Rails.logger.error "Exception Occurred #{e.class}. Message: #{e.message}. Backtrace: \n #{e.backtrace.join("\n")}"
+ File.write(target, content)
end
+
+ puts 'Workspace setup completed successfully 🎉'
+rescue StandardError => e
+ puts "Exception Occurred #{e.class}. Message: #{e.message}. Backtrace: \n #{e.backtrace.join("\n")}"
+ Rails.logger.error "Exception Occurred #{e.class}. Message: #{e.message}. Backtrace: \n #{e.backtrace.join("\n")}"
end
# Run the secret task, grab the output, strip the new lines
diff --git a/app/controllers/allies_controller.rb b/app/controllers/allies_controller.rb
index 61d6784c96..d207fa9b91 100644
--- a/app/controllers/allies_controller.rb
+++ b/app/controllers/allies_controller.rb
@@ -18,14 +18,14 @@ def index
def add
AllyshipCreator.perform(ally_id: params[:ally_id],
- current_user: current_user)
+ current_user:)
redirect_to_path(allies_path)
end
def remove
user_id = current_user.id
ally_id = params[:ally_id].to_i
- Allyship.where(user_id: user_id, ally_id: ally_id).destroy_all
+ Allyship.where(user_id:, ally_id:).destroy_all
redirect_to_path(allies_path)
end
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 3904f72073..5dfbfa3381 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -17,9 +17,9 @@ class ApplicationController < ActionController::Base
private
- def with_timezone
+ def with_timezone(&)
timezone = Time.find_zone(cookies[:timezone])
- Time.use_zone(timezone) { yield }
+ Time.use_zone(timezone, &)
end
def set_locale
@@ -64,9 +64,7 @@ def configure_for_accept_invitation
end
def after_sign_in_path_for(resource)
- if resource.respond_to?(:pwned?) && resource.pwned?
- cookies[:pwned] = { value: true, expires: Time.current + 10.minutes }
- end
+ cookies[:pwned] = { value: true, expires: 10.minutes.from_now } if resource.respond_to?(:pwned?) && resource.pwned?
super
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index d793cb7325..bde5ea57ec 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -25,7 +25,7 @@ def delete
def remove_meeting_notification!(comment_id)
CommentNotificationsService.remove(
- comment_id: comment_id,
+ comment_id:,
model_name: 'Meeting'
)
end
diff --git a/app/controllers/concerns/moments_concern.rb b/app/controllers/concerns/moments_concern.rb
index 152283c6de..9e2d7878b2 100644
--- a/app/controllers/concerns/moments_concern.rb
+++ b/app/controllers/concerns/moments_concern.rb
@@ -17,9 +17,7 @@ def saving_as_draft?
def empty_array_for(*symbols)
symbols.each do |symbol|
- if moment_params[symbol].nil? && @moment.has_attribute?(symbol)
- @moment[symbol] = []
- end
+ @moment[symbol] = [] if moment_params[symbol].nil? && @moment.has_attribute?(symbol)
end
end
end
diff --git a/app/controllers/concerns/shared.rb b/app/controllers/concerns/shared.rb
index 123a5897a1..f1c2bd3ed3 100644
--- a/app/controllers/concerns/shared.rb
+++ b/app/controllers/concerns/shared.rb
@@ -88,7 +88,7 @@ def format_success(format, model_object, is_update)
path = show_path(model_object)
format.html { redirect_to path }
status = is_update ? :ok : :created
- format.json { render :show, status: status, location: model_object }
+ format.json { render :show, status:, location: model_object }
end
def format_failure(format, model_object, is_update)
diff --git a/app/controllers/concerns/strategies_concern.rb b/app/controllers/concerns/strategies_concern.rb
index 071da1e0ae..1d9a677d9b 100644
--- a/app/controllers/concerns/strategies_concern.rb
+++ b/app/controllers/concerns/strategies_concern.rb
@@ -22,9 +22,7 @@ def render_errors(strategy)
def empty_array_for(*symbols)
symbols.each do |symbol|
- if strategy_params[symbol].nil? && @strategy.has_attribute?(symbol)
- @strategy[symbol] = []
- end
+ @strategy[symbol] = [] if strategy_params[symbol].nil? && @strategy.has_attribute?(symbol)
end
end
diff --git a/app/controllers/groups/memberships_controller.rb b/app/controllers/groups/memberships_controller.rb
index b3c53f0a51..04238934aa 100644
--- a/app/controllers/groups/memberships_controller.rb
+++ b/app/controllers/groups/memberships_controller.rb
@@ -13,7 +13,7 @@ def create
flash[:notice] = t('groups.join.success')
redirect_to_group
- rescue
+ rescue StandardError
flash[:alert] = t('groups.join.group_not_exists')
redirect_to groups_path
end
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 41e7650e28..3ec2214963 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -19,9 +19,7 @@ def index
# GET /groups/1
# GET /groups/1.json
def show
- if @group.members.include? current_user
- @meetings = @group.meetings.includes(:leaders)
- end
+ @meetings = @group.meetings.includes(:leaders) if @group.members.include? current_user
@page_new = t('meetings.new') if @group.led_by?(current_user)
end
diff --git a/app/controllers/medications_controller.rb b/app/controllers/medications_controller.rb
index 14b2083ad5..32af6ee6e0 100644
--- a/app/controllers/medications_controller.rb
+++ b/app/controllers/medications_controller.rb
@@ -54,7 +54,7 @@ def add_refill(medication)
dosage = @medication&.dosage || medication[:dosage]
no_of_days = total.to_i / dosage.to_i
no_of_weeks = no_of_days.to_i / weekly_dosage.length
- days = 7 * no_of_weeks + (no_of_days % weekly_dosage.length)
+ days = (7 * no_of_weeks) + (no_of_days % weekly_dosage.length)
Time.zone.now.strftime('%d/%m/%Y').to_date + days - 1
end
diff --git a/app/controllers/meetings_controller.rb b/app/controllers/meetings_controller.rb
index 7eebf59abd..3e1c8ddf7e 100644
--- a/app/controllers/meetings_controller.rb
+++ b/app/controllers/meetings_controller.rb
@@ -66,12 +66,12 @@ def leave
# Cannot leave When you are the only leader
if meeting.led_by?(current_user) && meeting.leaders.count == 1
redirect_to(group_path(meeting.group_id),
- alert: t('meetings.leave.error'))
+ alert: t('.error'))
else
# Remove user from meeting
meeting.meeting_members.find_by(user_id: current_user.id).destroy
redirect_to(group_path(meeting.group_id),
- notice: t('meetings.leave.success', meeting: meeting.name))
+ notice: t('.success', meeting: meeting.name))
end
end
@@ -107,10 +107,10 @@ def meeting_params
def send_notification(meeting, members, type)
MeetingNotificationsService.handle_members(
- current_user: current_user,
- meeting: meeting,
- type: type,
- members: members
+ current_user:,
+ meeting:,
+ type:,
+ members:
)
end
diff --git a/app/controllers/moments_controller.rb b/app/controllers/moments_controller.rb
index daa9af588f..3aa6198b08 100644
--- a/app/controllers/moments_controller.rb
+++ b/app/controllers/moments_controller.rb
@@ -27,7 +27,7 @@ def show
show_with_comments(@moment)
resources_data = get_resources_data(@moment, current_user)
@resources = ResourceRecommendations.new(
- moment: @moment, current_user: current_user
+ moment: @moment, current_user:
).call
@show_crisis_prevention = resources_data[:show_crisis_prevention]
@resources_tags = resources_data[:tags]
@@ -41,9 +41,7 @@ def new
# GET /moments/1/edit
def edit
- unless @moment.user_id == current_user.id
- redirect_to_path(moment_path(@moment))
- end
+ redirect_to_path(moment_path(@moment)) unless @moment.user_id == current_user.id
set_association_variables!
end
diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb
index 11e1273706..88c8cb8005 100644
--- a/app/controllers/profile_controller.rb
+++ b/app/controllers/profile_controller.rb
@@ -29,7 +29,7 @@ def remove_ban
private
def update_and_email(user, banned)
- user.update(banned: banned)
+ user.update(banned:)
if banned
BannedMailer.add_ban_email(user).deliver_now
else
@@ -53,8 +53,8 @@ def ban(banned)
def notice_or_alert(user, notice)
name = user&.name || params[:user_id]
- return { notice: t("reports.#{notice}", name: name) } if user.present?
+ return { notice: t("reports.#{notice}", name:) } if user.present?
- { alert: t("reports.#{notice}_error", name: name) }
+ { alert: t("reports.#{notice}_error", name:) }
end
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 6369dacf86..ce28c8ff9a 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -23,7 +23,7 @@ def posts
private
def search_by_email(email)
- User.where(email: email)
+ User.where(email:)
.where.not(id: current_user.id)
.where.not(banned: true)
end
diff --git a/app/controllers/secret_shares_controller.rb b/app/controllers/secret_shares_controller.rb
index 75252e0468..f2c4ad2fdf 100644
--- a/app/controllers/secret_shares_controller.rb
+++ b/app/controllers/secret_shares_controller.rb
@@ -3,6 +3,12 @@
class SecretSharesController < ApplicationController
skip_before_action :if_not_signed_in, only: [:show]
+ def show
+ @moment = Moment.find_secret_share!(params[:id])
+ @page_author = User.find(@moment.user_id)
+ render 'moments/show'
+ end
+
def create
# Authorisation check will automatically raise ActiveRecord::RecordNotFound
moment = Moment.where(user: current_user).friendly.find(params[:moment])
@@ -13,12 +19,6 @@ def create
redirect_to moment_path(moment, anchor: 'secretShare')
end
- def show
- @moment = Moment.find_secret_share!(params[:id])
- @page_author = User.find(@moment.user_id)
- render 'moments/show'
- end
-
def destroy
moment = Moment.find_by!(user: current_user, id: params[:id])
moment.update!(secret_share_identifier: nil)
diff --git a/app/controllers/strategies_controller.rb b/app/controllers/strategies_controller.rb
index 08faaee5cc..865378d318 100644
--- a/app/controllers/strategies_controller.rb
+++ b/app/controllers/strategies_controller.rb
@@ -48,9 +48,7 @@ def new
# GET /strategies/1/edit
def edit
- unless @strategy.user_id == current_user.id
- redirect_to_path(strategy_path(@strategy))
- end
+ redirect_to_path(strategy_path(@strategy)) unless @strategy.user_id == current_user.id
@viewers = current_user.allies_by_status(:accepted)
@categories = current_user.categories.is_visible
.or(Category.where(id: @strategy.category_ids))
@@ -75,7 +73,7 @@ def premade
strategy = premade_strategy
respond_to do |format|
if strategy.save
- PerformStrategyReminder.create!(strategy: strategy, active: false)
+ PerformStrategyReminder.create!(strategy:, active: false)
format.json { head :no_content }
else
format.json { render_errors(strategy) }
@@ -124,7 +122,7 @@ def set_strategy
end
def quick_create_params(viewers)
- { user_id: current_user.id, comment: true, viewers: viewers, visible: true,
+ { user_id: current_user.id, comment: true, viewers:, visible: true,
description: params[:strategy][:description], published_at: Time.zone.now,
category: params[:strategy][:category], name: params[:strategy][:name] }
end
diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb
index 9468a17704..bfa7ac49e4 100644
--- a/app/controllers/users/invitations_controller.rb
+++ b/app/controllers/users/invitations_controller.rb
@@ -28,9 +28,7 @@ def update
AllyshipCreator.perform(ally_id: resource.id,
current_user: resource.invited_by)
if resource.class.allow_insecure_sign_in_after_accept
- # rubocop:disable Layout/LineLength
flash_message = resource.active_for_authentication? ? :updated : :updated_not_active
- # rubocop:enable Layout/LineLength
set_flash_message :notice, flash_message if is_flashing_format?
sign_in(resource_name, resource)
respond_with resource, location: after_accept_path_for(resource)
diff --git a/app/controllers/users/reports_controller.rb b/app/controllers/users/reports_controller.rb
index 0de28ce1b7..31f124aef8 100644
--- a/app/controllers/users/reports_controller.rb
+++ b/app/controllers/users/reports_controller.rb
@@ -6,22 +6,22 @@ class ReportsController < ApplicationController
def submit_request
status, response = submit_request_helper(current_user)
- render json: response, status: status
+ render json: response, status:
end
def fetch_request_status
status, response = fetch_request_status_helper(current_user,
params[:request_id])
- render json: response, status: status
+ render json: response, status:
end
def download_data
status, response = download_data_helper(current_user,
params[:request_id])
- if status != 200
- render json: response, status: status
- else
+ if status == 200
send_file(response, status: 200)
+ else
+ render(json: response, status:)
end
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5feb208ee1..d2330f6d00 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -20,32 +20,33 @@ def sign_in_path?
def page_title
t('app_name') +
- if sign_in_path?
- " | " + t('account.sign_in')
- elsif join_path?
- " | " + t('account.sign_up')
- elsif forgot_password_path?
- " | " + t('account.forgot_password')
- elsif update_account_path?
- " | " + t('account.singular')
- elsif current_page?(root_path)
- " | " + t('app_description')
- elsif send_ally_invitation_path?
- " | " + t('devise.invitations.new.header')
- elsif ally_accept_invitation_path?
- " | " + t('devise.invitations.edit.header')
- elsif reset_password_path?
- " | " + t('layouts.title.reset_password')
- elsif new_user_confirmation_path?
- " | " + t('devise.confirmations.resend_confirmation')
- else
- " | " + title_content
- end
+ if sign_in_path?
+ ' | ' + t('account.sign_in')
+ elsif join_path?
+ ' | ' + t('account.sign_up')
+ elsif forgot_password_path?
+ ' | ' + t('account.forgot_password')
+ elsif update_account_path?
+ ' | ' + t('account.singular')
+ elsif current_page?(root_path)
+ ' | ' + t('app_description')
+ elsif send_ally_invitation_path?
+ ' | ' + t('devise.invitations.new.header')
+ elsif ally_accept_invitation_path?
+ ' | ' + t('devise.invitations.edit.header')
+ elsif reset_password_path?
+ ' | ' + t('layouts.title.reset_password')
+ elsif new_user_confirmation_path?
+ ' | ' + t('devise.confirmations.resend_confirmation')
+ else
+ ' | ' + title_content
+ end
end
def title_content
content_for(:title) || 'a community for mental health experiences'
end
+
def join_path?
path = new_user_registration_path
devise_page?(path, 'registrations', 'create') ||
diff --git a/app/helpers/assets_helper.rb b/app/helpers/assets_helper.rb
index 512b228eb1..15cb62de70 100644
--- a/app/helpers/assets_helper.rb
+++ b/app/helpers/assets_helper.rb
@@ -20,11 +20,11 @@ def inline_css(path)
def inline_file(path, css = false)
if css && path == 'webpack_bundle.css'
- File.read(Rails.root.join('public', webpack_folder, path))
+ File.read(Rails.public_path.join(webpack_folder, path))
elsif Rails.application.assets
get_application_asset(path)
else
- File.read(Rails.root.join('public', asset_path(path)))
+ File.read(Rails.public_path.join(asset_path(path)))
end
end
diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb
index cf663748d0..eabbad8e78 100644
--- a/app/helpers/categories_helper.rb
+++ b/app/helpers/categories_helper.rb
@@ -39,7 +39,7 @@ def actions_setup(element, url_helper)
{
edit: {
name: t('common.actions.edit'),
- link: link
+ link:
},
delete: action_delete(url_helper),
not_visible: !element.visible && get_visible(element.visible),
diff --git a/app/helpers/comments_form_helper.rb b/app/helpers/comments_form_helper.rb
index a46dc5751f..db431f00a5 100644
--- a/app/helpers/comments_form_helper.rb
+++ b/app/helpers/comments_form_helper.rb
@@ -17,9 +17,7 @@ def comment_form_props(commentable, commentable_type)
def basic_props_overrides(props, input_type)
props = props.merge(dark: true) if input_type != 'hidden'
- if input_type == 'textarea'
- props = props.merge(required: true, label: t('comment.singular'))
- end
+ props = props.merge(required: true, label: t('comment.singular')) if input_type == 'textarea'
props
end
@@ -28,7 +26,7 @@ def basic_props(field, input_type, value = nil)
id: "comment_#{field}",
name: "comment[#{field}]",
type: input_type,
- value: value
+ value:
}
basic_props_overrides(props, input_type)
end
@@ -36,8 +34,8 @@ def basic_props(field, input_type, value = nil)
def comment_visibility_option(value, label)
{
id: "comment_visibility_#{value}",
- label: label,
- value: value
+ label:,
+ value:
}
end
@@ -63,8 +61,8 @@ def visibility_input_not_owner(owner)
def comment_viewers_option(field, label, value = nil)
{
id: "comment_viewers_#{field}",
- label: label,
- value: value
+ label:,
+ value:
}
end
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index b605bb0e41..6dd228c9ed 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -28,7 +28,7 @@ def quick_create_form_props(inputs, action)
private
def form_props(inputs, action)
- props = { inputs: inputs }
+ props = { inputs: }
props[:action] = action
props
end
diff --git a/app/helpers/groups_form_helper.rb b/app/helpers/groups_form_helper.rb
index 8d66c20b1e..993df311bd 100644
--- a/app/helpers/groups_form_helper.rb
+++ b/app/helpers/groups_form_helper.rb
@@ -59,7 +59,7 @@ def edit_inputs
id: 'group_leader',
name: 'group[leader]',
type: 'checkboxGroup',
- checkboxes: checkboxes,
+ checkboxes:,
label: t('groups.form.leaders'),
dark: true,
required: true
diff --git a/app/helpers/header_helper.rb b/app/helpers/header_helper.rb
index 026a398789..3ef7a17115 100644
--- a/app/helpers/header_helper.rb
+++ b/app/helpers/header_helper.rb
@@ -5,7 +5,7 @@ def header_props
{
home: { name: t('app_name'), url: root_path },
profile: user_signed_in? ? profile : nil,
- links: links,
+ links:,
mobileOnly: user_signed_in? ? mobile_only : nil
}
end
@@ -41,8 +41,8 @@ def profile
name: t('profile.index.title'),
url: profile_index_path(uid: current_user.uid)
},
- account: account,
- notifications: notifications
+ account:,
+ notifications:
}
end
diff --git a/app/helpers/medications_form_helper.rb b/app/helpers/medications_form_helper.rb
index 5ade2147c6..af46c15255 100644
--- a/app/helpers/medications_form_helper.rb
+++ b/app/helpers/medications_form_helper.rb
@@ -29,9 +29,9 @@ def refill_reminder(field, info, checked, label = nil)
id: "medication_#{field}",
type: 'checkbox',
label: label || t("medications.#{field}"),
- info: info,
+ info:,
name: "medication[#{field}][active]",
- checked: checked
+ checked:
}.merge(dark: true, uncheckedValue: false, value: true)
end
@@ -78,7 +78,7 @@ def hidden_props(field, value)
id: "medication_#{field}_id",
name: "medication[#{field}][id]",
type: 'hidden',
- value: value
+ value:
}
end
diff --git a/app/helpers/meetings_form_helper.rb b/app/helpers/meetings_form_helper.rb
index 6a0ade87f8..e296081b16 100644
--- a/app/helpers/meetings_form_helper.rb
+++ b/app/helpers/meetings_form_helper.rb
@@ -15,7 +15,7 @@ def edit_meeting_props(meeting)
def meeting_input_props(field, type, label, value)
{
id: "meeting_#{field}",
- type: type,
+ type:,
name: "meeting[#{field}]",
label: t(label),
value: value || nil,
diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rb
index 047573f6fa..6ff707c963 100644
--- a/app/helpers/meetings_helper.rb
+++ b/app/helpers/meetings_helper.rb
@@ -77,9 +77,7 @@ def spots(meeting)
def generate_google_cal_actions_hash(meeting)
return {} unless (meeting_member = meeting.meeting_member(current_user))
- if meeting_member.google_cal_event_id
- return remove_from_google_cal_hash(meeting)
- end
+ return remove_from_google_cal_hash(meeting) if meeting_member.google_cal_event_id
add_to_google_cal_hash(meeting)
end
diff --git a/app/helpers/moments_form_helper.rb b/app/helpers/moments_form_helper.rb
index 82b18daf27..782599704b 100644
--- a/app/helpers/moments_form_helper.rb
+++ b/app/helpers/moments_form_helper.rb
@@ -16,13 +16,13 @@ def edit_moment_props
private
def moment_input_props(field, type, label, group = false)
- { id: "moment_#{field}", type: type,
+ { id: "moment_#{field}", type:,
name: "moment[#{field}]#{group ? '[]' : ''}", label: t(label) }
end
def moment_text_input_props(field, type, label, required = false)
moment_input_props(field, type, label)
- .merge(value: @moment[field] || nil, required: required, dark: true)
+ .merge(value: @moment[field] || nil, required:, dark: true)
end
def moment_name
diff --git a/app/helpers/moments_helper.rb b/app/helpers/moments_helper.rb
index 255cda9f37..3bb2cb10d2 100644
--- a/app/helpers/moments_helper.rb
+++ b/app/helpers/moments_helper.rb
@@ -18,11 +18,13 @@ def moments_data_html
start_date = 1.week.ago.to_date
end_date = Date.tomorrow
range = start_date..end_date
+ return unless current_user.moments.exists?
+
@react_moments = current_user.moments
.where(updated_at: range)
.group_by_period(:day,
:created_at)
- .count if current_user.moments.exists?
+ .count
end
def moments_or_strategy_props(elements)
@@ -65,7 +67,7 @@ def present_moment_or_strategy(element)
link: present_object[:url_helper],
date: TimeAgo.created_or_edited(element),
actions: element_actions(element, present_object),
- draft: !element.published? ? t('draft') : nil,
+ draft: element.published? ? nil : t('draft'),
categories: element.category_names_and_slugs,
moods: present_object[:moods],
storyBy: story_by(element),
@@ -75,7 +77,7 @@ def present_moment_or_strategy(element)
def get_resources_data(moment, current_user)
unless moment.shared?
r = ResourceRecommendations.new(
- moment: moment, current_user: current_user
+ moment:, current_user:
)
tags = r.matched_tags.uniq.map do |t|
"filter[]=#{t}&"
diff --git a/app/helpers/moments_stats_helper.rb b/app/helpers/moments_stats_helper.rb
index 4feea1a9b4..3632ef41e3 100644
--- a/app/helpers/moments_stats_helper.rb
+++ b/app/helpers/moments_stats_helper.rb
@@ -6,9 +6,7 @@ def moments_stats
result = '
'
result += total_moment
- if moment_count[:total] != moment_count[:monthly]
- result += " #{monthly_moment}"
- end
+ result += " #{monthly_moment}" if moment_count[:total] != moment_count[:monthly]
result + '
'
end
diff --git a/app/helpers/most_focus_helper.rb b/app/helpers/most_focus_helper.rb
index 26df96e318..93a87dd6ab 100644
--- a/app/helpers/most_focus_helper.rb
+++ b/app/helpers/most_focus_helper.rb
@@ -33,9 +33,7 @@ def get_visible_data_for(data, data_type)
def get_data(data_type, user)
data = get_data_type(user.moments.published, data_type)
- if data_type == 'category'
- data.concat(get_data_type(user.strategies.published, data_type))
- end
+ data.concat(get_data_type(user.strategies.published, data_type)) if data_type == 'category'
data
end
diff --git a/app/helpers/notification_mailer_helper.rb b/app/helpers/notification_mailer_helper.rb
index c479d40c34..9fae2bc31d 100644
--- a/app/helpers/notification_mailer_helper.rb
+++ b/app/helpers/notification_mailer_helper.rb
@@ -36,7 +36,7 @@ def comment_text(data, key)
end
def comment_link(link)
- I18n.t(val('comment_link'), link: link)
+ I18n.t(val('comment_link'), link:)
end
def new_group_subject(data)
@@ -77,7 +77,7 @@ def add_remove_group_leader_body(data)
link = link_to(link_name, group_url(data['group_id']))
I18n.t(val('add_remove_group_leader_body'),
group: data['group'].to_s,
- link: link)
+ link:)
end
def remove_group_leader_you_subject(data)
@@ -111,12 +111,12 @@ def meeting_body(data)
def new_meeting_link(data)
link_name = I18n.t('click_here')
link = link_to(link_name, meeting_url(data['typeid']))
- I18n.t(val('new_meeting_link'), link: link)
+ I18n.t(val('new_meeting_link'), link:)
end
def update_meeting_link(data)
link = body_link(meeting_url(data['typeid']))
- I18n.t(val('update_meeting_link'), link: link)
+ I18n.t(val('update_meeting_link'), link:)
end
def remove_meeting_subject(data)
@@ -129,7 +129,7 @@ def join_meeting_subject(data)
def join_meeting_body(data)
link = body_link(meeting_url(data['typeid']))
- I18n.t(val('join_meeting_body'), meeting: data['typename'].to_s, link: link)
+ I18n.t(val('join_meeting_body'), meeting: data['typename'].to_s, link:)
end
def val(key)
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 927ff0aac7..e8b55d24fc 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -61,9 +61,7 @@ def specific_meeting_link(type, typeid, group_id)
def request_accept(user_id)
add = "/allies/add?ally_id=#{user_id}"
- # rubocop:disable Layout/LineLength
"#{t('allies.accept')}"
- # rubocop:enable Layout/LineLength
end
def request_reject(user_id)
diff --git a/app/helpers/reminder_helper.rb b/app/helpers/reminder_helper.rb
index a18bdfec4e..9b95da15f9 100644
--- a/app/helpers/reminder_helper.rb
+++ b/app/helpers/reminder_helper.rb
@@ -4,9 +4,7 @@ def print_reminders(data)
return '' unless reminders?(data)
names_arr = data.active_reminders.map(&:name)
- if data[:add_to_google_cal]
- names_arr.push(t('medications.form.add_to_google_cal'))
- end
+ names_arr.push(t('medications.form.add_to_google_cal')) if data[:add_to_google_cal]
format_reminders(names_arr).html_safe
end
diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb
index 6c496b17b2..c601fb3563 100644
--- a/app/helpers/reports_helper.rb
+++ b/app/helpers/reports_helper.rb
@@ -5,7 +5,7 @@ module ReportsHelper
def new_report_props(uid, comment_id = nil)
new_form_props(
report_form_inputs,
- reports_path(uid: uid, comment_id: comment_id)
+ reports_path(uid:, comment_id:)
)
end
diff --git a/app/helpers/strategies_form_helper.rb b/app/helpers/strategies_form_helper.rb
index 706001bcda..29ee14201f 100644
--- a/app/helpers/strategies_form_helper.rb
+++ b/app/helpers/strategies_form_helper.rb
@@ -96,9 +96,9 @@ def build_strategy_visible(strategy)
def build_switch_input(value, checked, unchecked_value)
{
- type: 'switch', value: value,
+ type: 'switch', value:,
uncheckedValue: unchecked_value,
- checked: checked,
+ checked:,
dark: true
}
end
diff --git a/app/helpers/users/reports_helper.rb b/app/helpers/users/reports_helper.rb
index dfd3ea05f0..5d9da6dd4a 100644
--- a/app/helpers/users/reports_helper.rb
+++ b/app/helpers/users/reports_helper.rb
@@ -10,10 +10,8 @@ def submit_request_helper(user)
def fetch_request_status_helper(user, request_id)
return 400, { error: "Request id can't be blank." } if request_id.blank?
- data_request = user.data_requests.find_by(request_id: request_id)
- if data_request.blank?
- return 404, { error: 'No such request exists for current user.' }
- end
+ data_request = user.data_requests.find_by(request_id:)
+ return 404, { error: 'No such request exists for current user.' } if data_request.blank?
[200, { current_status: data_request.status_id }]
end
@@ -22,7 +20,7 @@ def download_data_helper(user, request_id)
return 400, { error: "Request id can't be blank." } if request_id.blank?
data_request = user.data_requests.find_by(
- request_id: request_id,
+ request_id:,
status_id: Users::DataRequest::STATUS[:success]
)
if data_request.blank? || !File.exist?(data_request.file_path.to_s)
diff --git a/app/helpers/viewers_helper.rb b/app/helpers/viewers_helper.rb
index 4f174cc9c5..68112cab9a 100644
--- a/app/helpers/viewers_helper.rb
+++ b/app/helpers/viewers_helper.rb
@@ -15,9 +15,7 @@ def get_viewers_for(data, data_type)
result = []
if data && %w[categories moods strategies].include?(data_type)
result += get_viewers(data, data_type, Moment)
- if data_type == 'categories'
- result += get_viewers(data, data_type, Strategy)
- end
+ result += get_viewers(data, data_type, Strategy) if data_type == 'categories'
end
result.uniq
end
@@ -61,7 +59,7 @@ def only_you_as_viewer(link)
def get_viewer_list(data, link)
return only_you_as_viewer(link) if data.blank?
- names = data.to_a.map { |id| User.find_by(id: id).name }.to_sentence
+ names = data.to_a.map { |id| User.find_by(id:).name }.to_sentence
link ? t('shared.viewers.many', viewers: names) : names
end
diff --git a/app/mailers/ally_notifications/new_ally_request.rb b/app/mailers/ally_notifications/new_ally_request.rb
index 1ee541d311..55df30410b 100644
--- a/app/mailers/ally_notifications/new_ally_request.rb
+++ b/app/mailers/ally_notifications/new_ally_request.rb
@@ -19,7 +19,7 @@ def subject
end
def message
- I18n.t('mailers.new_ally_request.message', allies_url: allies_url)
+ I18n.t('mailers.new_ally_request.message', allies_url:)
end
end
end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 286c794bb5..ae2db0be51 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -5,7 +5,7 @@ class ApplicationMailer < ActionMailer::Base
include ApplicationMailerHelper
include NotificationMailerHelper
include GroupNotificationHelper
- default from: ENV['SMTP_FROM']
+ default from: ENV.fetch('SMTP_FROM', nil)
layout 'mailer'
ALLY_NOTIFY_TYPES = %w[new_ally_request accepted_ally_request].freeze
@@ -15,7 +15,7 @@ def reminder_mailer(model, subject_text)
@model = model
@user = @model.user
subject = I18n.t(subject_text, name: @model.name)
- mail(to: @user.email, subject: subject)
+ mail(to: @user.email, subject:)
end
def can_comment_notify(data, recipient)
@@ -26,7 +26,7 @@ def comment_notify(data, recipient)
subject = extract_comment_notify_subject(data)
generate_comment_notify_message(data)
@recipient = recipient
- mail(to: recipient.email, subject: subject)
+ mail(to: recipient.email, subject:)
end
def can_ally_notify(data, recipient)
diff --git a/app/mailers/banned_mailer.rb b/app/mailers/banned_mailer.rb
index 743e0c598e..f856a6276a 100644
--- a/app/mailers/banned_mailer.rb
+++ b/app/mailers/banned_mailer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class BannedMailer < ApplicationMailer
- default from: ENV['SMTP_FROM']
+ default from: ENV.fetch('SMTP_FROM', nil)
def add_ban_email(recipient)
@recipient = recipient
diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb
index fdb36d6c38..6b17a7d893 100644
--- a/app/mailers/notification_mailer.rb
+++ b/app/mailers/notification_mailer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class NotificationMailer < ApplicationMailer
- default from: ENV['SMTP_FROM']
+ default from: ENV.fetch('SMTP_FROM', nil)
def take_medication(reminder)
return if reminder.medication.blank?
@@ -31,7 +31,7 @@ def meeting_reminder(meeting, member)
time: @meeting.time
)
- mail(to: @member.email, subject: subject)
+ mail(to: @member.email, subject:)
end
def notification_email(recipientid, data)
diff --git a/app/mailers/report_mailer.rb b/app/mailers/report_mailer.rb
index 37d10a77bb..fc336232ef 100644
--- a/app/mailers/report_mailer.rb
+++ b/app/mailers/report_mailer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class ReportMailer < ApplicationMailer
- default from: ENV['SMTP_FROM']
+ default from: ENV.fetch('SMTP_FROM', nil)
def reported_email(recipient, reportee)
@recipient = recipient
diff --git a/app/models/allyship.rb b/app/models/allyship.rb
index 284672c088..589892e7ad 100644
--- a/app/models/allyship.rb
+++ b/app/models/allyship.rb
@@ -27,10 +27,10 @@ class Allyship < ApplicationRecord
belongs_to :user
belongs_to :ally, class_name: 'User'
- before_destroy :remove_activities_between_users
-
after_create :create_inverse, unless: :inverse?
after_update :approve_inverse, if: :inverse_unapproved?
+ before_destroy :remove_activities_between_users
+
after_destroy :destroy_inverses, if: :inverse?
def approve_inverse
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 55263e298a..1cea790eb7 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -8,8 +8,8 @@ def self.build_csv_rows(objects)
klass = objects.klass
data = [["#{klass.name.underscore}_info"]]
- attributes = if klass.const_defined?('USER_DATA_ATTRIBUTES')
- klass.const_get('USER_DATA_ATTRIBUTES')
+ attributes = if klass.const_defined?(:USER_DATA_ATTRIBUTES)
+ klass.const_get(:USER_DATA_ATTRIBUTES)
else
klass.column_names
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 1a0e4f7ffd..6874ba3dd9 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -41,7 +41,7 @@ def create_from!(params)
comment_by: params[:comment_by],
comment: params[:comment],
visibility: viewers.any? ? 'private' : params[:visibility],
- viewers: viewers
+ viewers:
)
end
@@ -86,7 +86,7 @@ def notification_data(creator, association, type, unique_id)
commentid: id,
comment: comment[0..80],
cutoff: comment.length > 80,
- type: type,
+ type:,
typeid: association.id,
uniqueid: unique_id,
typename: association.name
@@ -95,11 +95,11 @@ def notification_data(creator, association, type, unique_id)
def notifications!(data, user_id)
Notification.create!(
- user_id: user_id,
+ user_id:,
uniqueid: unique_id(type),
- data: data
+ data:
)
- model_data = Notification.where(user_id: user_id)
+ model_data = Notification.where(user_id:)
model_data.order('created_at')
end
@@ -111,7 +111,7 @@ def notify_of_creation?(association)
def send_notification(data, notifications, user_id)
Pusher["private-#{user_id}"]
- .trigger('new_notification', notifications: notifications)
+ .trigger('new_notification', notifications:)
NotificationMailer.notification_email(user_id, data).deliver_now
end
diff --git a/app/models/concerns/common_methods.rb b/app/models/concerns/common_methods.rb
index 5b59ca5644..d9ebe304ce 100644
--- a/app/models/concerns/common_methods.rb
+++ b/app/models/concerns/common_methods.rb
@@ -21,7 +21,7 @@ def elements_array_data(elements)
if send(element).is_a?(Array)
element_ids = send(element).collect(&:to_i)
send("#{associated_elements}=",
- klass.where(user_id: user_id, id: element_ids))
+ klass.where(user_id:, id: element_ids))
else
send("#{associated_elements}=", klass.none)
end
@@ -31,6 +31,6 @@ def elements_array_data(elements)
private
def names_and_slugs_hash(data, model_name)
- data.map { |name, slug| { name: name, slug: "/#{model_name}/#{slug}" } }
+ data.map { |name, slug| { name:, slug: "/#{model_name}/#{slug}" } }
end
end
diff --git a/app/models/concerns/viewer.rb b/app/models/concerns/viewer.rb
index 40ae86cba9..efb5887fd4 100644
--- a/app/models/concerns/viewer.rb
+++ b/app/models/concerns/viewer.rb
@@ -10,12 +10,12 @@ def viewer?(user)
class_methods do
def destroy_viewer(user_id, viewer_id)
- where(user_id: user_id).find_each do |instance|
+ where(user_id:).find_each do |instance|
viewers = instance.viewers
if viewers.include?(viewer_id)
viewers.delete(viewer_id)
- update(instance.id, viewers: viewers)
+ update(instance.id, viewers:)
end
end
end
diff --git a/app/models/group_member.rb b/app/models/group_member.rb
index d335f0ab49..40c82e4414 100644
--- a/app/models/group_member.rb
+++ b/app/models/group_member.rb
@@ -26,7 +26,7 @@ class GroupMember < ApplicationRecord
validates :leader, inclusion: [true, false]
belongs_to :group
- belongs_to :user, foreign_key: :user_id
+ belongs_to :user
has_many :meetings, through: :group
has_many :meeting_memberships,
diff --git a/app/models/medication.rb b/app/models/medication.rb
index f746ac43b4..0ccd982c2a 100644
--- a/app/models/medication.rb
+++ b/app/models/medication.rb
@@ -46,7 +46,7 @@ class Medication < ApplicationRecord
extend FriendlyId
friendly_id :name
- belongs_to :user, foreign_key: :user_id
+ belongs_to :user
has_one :take_medication_reminder, dependent: :destroy
has_one :refill_reminder, dependent: :destroy
accepts_nested_attributes_for :take_medication_reminder
diff --git a/app/models/meeting.rb b/app/models/meeting.rb
index 76a3b186c6..1ff6d92145 100644
--- a/app/models/meeting.rb
+++ b/app/models/meeting.rb
@@ -21,8 +21,8 @@ class Meeting < ApplicationRecord
friendly_id :name
validates :name, :description, :location, :time, :group_id, :date,
presence: true
- belongs_to :group, foreign_key: :group_id
- has_many :meeting_members, foreign_key: :meeting_id, dependent: :destroy
+ belongs_to :group
+ has_many :meeting_members, dependent: :destroy
has_many :members, -> { order 'name' }, through: :meeting_members,
source: :user
has_many :leaders, -> { where(meeting_members: { leader: true }) },
diff --git a/app/models/meeting_member.rb b/app/models/meeting_member.rb
index d71ca4cd0e..3f2960f22a 100644
--- a/app/models/meeting_member.rb
+++ b/app/models/meeting_member.rb
@@ -25,7 +25,7 @@ class MeetingMember < ApplicationRecord
validates :meeting_id, :user_id, presence: true
validates :leader, inclusion: [true, false]
- belongs_to :meeting, foreign_key: :meeting_id
- belongs_to :user, foreign_key: :user_id
+ belongs_to :meeting
+ belongs_to :user
belongs_to :group_member, foreign_key: :user_id, optional: true
end
diff --git a/app/models/notification.rb b/app/models/notification.rb
index b2fc8283d2..31bbca9e04 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -21,11 +21,11 @@ class Notification < ApplicationRecord
].map!(&:freeze).freeze
validates :user_id, :uniqueid, :data, presence: true
- belongs_to :user, foreign_key: :user_id
+ belongs_to :user
scope :for_ally, lambda { |user_id, ally_id|
where(
- user_id: user_id,
+ user_id:,
uniqueid: %W[new_ally_request_#{ally_id} accepted_ally_request_#{ally_id}]
)
}
diff --git a/app/models/user.rb b/app/models/user.rb
index cf252e6bf3..770eb4c627 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -97,20 +97,18 @@ class User < ApplicationRecord
has_many :allyships
has_many :allies, through: :allyships
- has_many :group_members, foreign_key: :user_id
+ has_many :group_members
has_many :groups, through: :group_members
- has_many :meeting_members, foreign_key: :user_id
- has_many :medications, foreign_key: :user_id
+ has_many :meeting_members
+ has_many :medications
has_many :strategies
- has_many :notifications, foreign_key: :user_id
+ has_many :notifications
has_many :moods
has_many :moments
has_many :categories
has_many :care_plan_contacts
has_many :moment_templates
- # rubocop:disable Layout/LineLength
- has_many :data_requests, class_name: 'Users::DataRequest', foreign_key: :user_id
- # rubocop:enable Layout/LineLength
+ has_many :data_requests, class_name: 'Users::DataRequest'
belongs_to :invited_by, class_name: 'User', optional: true
after_initialize :set_defaults, unless: :persisted?
@@ -139,14 +137,14 @@ def self.find_for_oauth(auth)
user = find_or_initialize_by(email: auth.info.email)
user.name ||= auth.info.name
user.password ||= Devise.friendly_token[0, 20]
- update_access_token_fields(user: user, access_token: auth)
+ update_access_token_fields(user:, access_token: auth)
user
end
def self.from_omniauth(auth)
where(provider: auth.provider,
uid: auth.provider + auth.uid).first_or_create do |user|
- UserBuilder::Builder.build(user: user, auth: auth)
+ UserBuilder::Builder.build(user:, auth:)
end
end
@@ -172,8 +170,8 @@ def set_defaults
def update_access_token
params = { 'refresh_token' => refresh_token,
- 'client_id' => ENV['GOOGLE_CLIENT_ID'],
- 'client_secret' => ENV['GOOGLE_CLIENT_SECRET'],
+ 'client_id' => ENV.fetch('GOOGLE_CLIENT_ID', nil),
+ 'client_secret' => ENV.fetch('GOOGLE_CLIENT_SECRET', nil),
'grant_type' => 'refresh_token' }
response = Net::HTTP.post_form(URI.parse(OAUTH_TOKEN_URL), params)
decoded_response = JSON.parse(response.body)
@@ -208,7 +206,7 @@ def generate_data_request
.where(status_id: Users::DataRequest::STATUS[:enqueued])
.first_or_initialize
if data_request.request_id.present?
- data_request.request_id
+ data_request.request_id
else
data_request.request_id = SecureRandom.uuid
data_request.save!
diff --git a/app/models/users/data_request.rb b/app/models/users/data_request.rb
index 2c2fefad2b..240c116d49 100644
--- a/app/models/users/data_request.rb
+++ b/app/models/users/data_request.rb
@@ -34,16 +34,16 @@ class DataRequest < ApplicationRecord
meeting_members
].freeze
- DEFAULT_FILE_PATH = Rails.root.join('tmp', 'csv_data')
+ DEFAULT_FILE_PATH = Rails.root.join('tmp/csv_data')
- belongs_to :user, class_name: '::User', foreign_key: 'user_id'
+ belongs_to :user, class_name: '::User'
after_commit :after_commit_tasks
validates :user_id, uniqueness: {
- scope: :status_id,
- message: 'There is already a request enqueued for this user.'
- },
+ scope: :status_id,
+ message: 'There is already a request enqueued for this user.'
+ },
if: -> { status_id == STATUS[:enqueued] }
validates :request_id, uniqueness: {
@@ -51,9 +51,9 @@ class DataRequest < ApplicationRecord
}
validates :status_id, inclusion: {
- in: STATUS.values,
- message: proc { |request| "'#{request.status_id}' is not valid." }
- },
+ in: STATUS.values,
+ message: proc { |request| "'#{request.status_id}' is not valid." }
+ },
presence: true
validates :request_id, presence: true
diff --git a/app/services/allyship_creator.rb b/app/services/allyship_creator.rb
index 2175e23d49..b6352e9a80 100644
--- a/app/services/allyship_creator.rb
+++ b/app/services/allyship_creator.rb
@@ -18,9 +18,9 @@ def perform
setup_allyship
remove_request
- notifier.perform(pusher_type: pusher_type,
- current_user: current_user,
- ally_id: ally_id)
+ notifier.perform(pusher_type:,
+ current_user:,
+ ally_id:)
end
private
@@ -28,7 +28,7 @@ def perform
def allyship
return @allyship if defined?(@allyship)
- @allyship = Allyship.find_by(ally_id: ally_id, user_id: current_user.id)
+ @allyship = Allyship.find_by(ally_id:, user_id: current_user.id)
end
def valid?
@@ -44,7 +44,7 @@ def pusher_type
def create_allyship
Allyship.create(
user_id: current_user.id,
- ally_id: ally_id,
+ ally_id:,
status: :pending_from_ally
)
end
diff --git a/app/services/allyships/alliance_notifier.rb b/app/services/allyships/alliance_notifier.rb
index 7992241f42..568371647e 100644
--- a/app/services/allyships/alliance_notifier.rb
+++ b/app/services/allyships/alliance_notifier.rb
@@ -36,7 +36,7 @@ def send_notification_mailer
def trigger_pusher
Pusher["private-#{ally_id}"]
- .trigger('new_notification', notifications: notifications)
+ .trigger('new_notification', notifications:)
end
def create_notification
diff --git a/app/services/calendar_uploader.rb b/app/services/calendar_uploader.rb
index f6634c15de..a238118226 100644
--- a/app/services/calendar_uploader.rb
+++ b/app/services/calendar_uploader.rb
@@ -14,7 +14,7 @@ def initialize(access_token)
def upload_event(summary, date)
parsed_date = date.to_time.iso8601
- event = { summary: summary,
+ event = { summary:,
start: { date_time: parsed_date },
end: { date_time: parsed_date } }
diff --git a/app/services/cloudinary_service.rb b/app/services/cloudinary_service.rb
index e5d0d482bf..838c54eede 100644
--- a/app/services/cloudinary_service.rb
+++ b/app/services/cloudinary_service.rb
@@ -23,7 +23,7 @@ def upload(file, options = {})
end
def fetch(public_id)
- ENV['CLOUDINARY_SECURE_URL'] + public_id
+ ENV.fetch('CLOUDINARY_SECURE_URL', nil) + public_id
end
def delete(public_id, options = {})
diff --git a/app/services/comment_viewers_service.rb b/app/services/comment_viewers_service.rb
index 8ea5ace627..28ba100bd7 100644
--- a/app/services/comment_viewers_service.rb
+++ b/app/services/comment_viewers_service.rb
@@ -20,9 +20,7 @@ def initialize(comment, current_user)
@comment = comment
@owner = commentable[:user_id] && User.find(commentable[:user_id])
@commentable_viewers =
- unless commentable.nil?
- commentable[:viewers] || commentable.members&.pluck(:id)
- end
+ (commentable[:viewers] || commentable.members&.pluck(:id) unless commentable.nil?)
@current_user = current_user
end
diff --git a/app/services/group_notifier.rb b/app/services/group_notifier.rb
index da1be488a7..556c680e87 100644
--- a/app/services/group_notifier.rb
+++ b/app/services/group_notifier.rb
@@ -25,14 +25,14 @@ def push_notifications(recipient)
notifications = Notification.where(user_id: recipient.id)
.order('created_at ASC')
Pusher["private-#{recipient.id}"]
- .trigger('new_notification', notifications: notifications)
+ .trigger('new_notification', notifications:)
end
def create_notification(recipient)
Notification.create(
user_id: recipient.id,
- uniqueid: uniqueid,
- data: data
+ uniqueid:,
+ data:
)
end
@@ -43,7 +43,7 @@ def data
group_id: @group.id,
group: @group.name,
type: @type,
- uniqueid: uniqueid
+ uniqueid:
}.to_json
end
diff --git a/app/services/medication_reminders.rb b/app/services/medication_reminders.rb
index 3406f2cfb8..24b8e81fef 100644
--- a/app/services/medication_reminders.rb
+++ b/app/services/medication_reminders.rb
@@ -22,6 +22,6 @@ def ready_for_refill
end
def one_week_from_now_as_string
- (Time.current + 1.week).strftime('%m/%d/%Y')
+ 1.week.from_now.strftime('%m/%d/%Y')
end
end
diff --git a/app/services/meeting_notifications_service.rb b/app/services/meeting_notifications_service.rb
index d296736ccb..4b1771b189 100644
--- a/app/services/meeting_notifications_service.rb
+++ b/app/services/meeting_notifications_service.rb
@@ -27,8 +27,8 @@ def handle_members
def get_notifications(member, data)
Notification.create!(
user_id: member.id,
- uniqueid: uniqueid,
- data: data
+ uniqueid:,
+ data:
)
Notification.where(user_id: member.id)
.order('created_at ASC').all
@@ -49,8 +49,8 @@ def remove_meeting_data
group_id: meeting.group_id,
group: meeting.group.name,
typename: meeting.name,
- type: type,
- uniqueid: uniqueid
+ type:,
+ uniqueid:
}.to_json
end
@@ -61,8 +61,8 @@ def new_or_update_meeting_data
typeid: meeting.id,
group: meeting.group.name,
typename: meeting.name,
- type: type,
- uniqueid: uniqueid
+ type:,
+ uniqueid:
}.to_json
end
diff --git a/app/services/profile_picture.rb b/app/services/profile_picture.rb
index 14b406f71a..dcb348942b 100644
--- a/app/services/profile_picture.rb
+++ b/app/services/profile_picture.rb
@@ -15,7 +15,7 @@ def fetch(path, options = {})
src: normalize_url(path),
small: options[:small] || nil,
large: options[:large] || nil,
- alt: alt
+ alt:
}
end
@@ -49,7 +49,7 @@ def get_cloudinary_url(path, type)
end
def claudinary_params(type)
- { type: type,
+ { type:,
format: 'jpg',
quality: 'auto:good',
width: DEFAULT_SIZE,
@@ -61,8 +61,8 @@ def claudinary_params(type)
end
def get_local_url(path)
- "#{Rails.application.config.force_ssl ? 'https' : 'http'}://"\
- "#{Rails.application.config.action_controller.asset_host}#{path}"
+ "#{Rails.application.config.force_ssl ? 'https' : 'http'}://" \
+ "#{Rails.application.config.action_controller.asset_host}#{path}"
end
end
end
diff --git a/app/services/time_ago.rb b/app/services/time_ago.rb
index 9296ee023e..d38f1383da 100644
--- a/app/services/time_ago.rb
+++ b/app/services/time_ago.rb
@@ -18,10 +18,10 @@ def created_or_edited(model)
formatted_created = formatted_ago(model.created_at)
formatted_updated = formatted_ago(model.updated_at)
- if model.created_at != model.updated_at
- edited(formatted_created, formatted_updated)
- else
+ if model.created_at == model.updated_at
I18n.t('created', created_at: formatted_created).html_safe
+ else
+ edited(formatted_created, formatted_updated)
end
end
diff --git a/app/workers/delete_stale_data_worker.rb b/app/workers/delete_stale_data_worker.rb
index 47ef77dbb9..2b366cd47a 100644
--- a/app/workers/delete_stale_data_worker.rb
+++ b/app/workers/delete_stale_data_worker.rb
@@ -9,9 +9,7 @@ def perform
.where('updated_at < ?', (Time.current - ACTIVE_DURATION))
.where(status_id: Users::DataRequest::STATUS[:success])
.each do |dr|
- if dr.file_path.present? && File.exist?(dr.file_path)
- File.delete(dr.file_path)
- end
+ File.delete(dr.file_path) if dr.file_path.present? && File.exist?(dr.file_path)
dr.update(status_id: Users::DataRequest::STATUS[:deleted])
end
end
diff --git a/app/workers/process_data_request_worker.rb b/app/workers/process_data_request_worker.rb
index eaaa8e61bc..6c17626f24 100644
--- a/app/workers/process_data_request_worker.rb
+++ b/app/workers/process_data_request_worker.rb
@@ -4,7 +4,7 @@ class ProcessDataRequestWorker
sidekiq_options queue: 'critical'
def perform(request_id)
- data_request = Users::DataRequest.find_by(request_id: request_id)
+ data_request = Users::DataRequest.find_by(request_id:)
return if data_request.blank? ||
data_request.status_id == Users::DataRequest::STATUS[:success]
diff --git a/config.ru b/config.ru
index 5d50a4e4d5..ada7ca0002 100644
--- a/config.ru
+++ b/config.ru
@@ -8,5 +8,5 @@ use Rack::Rewrite do
r301(/.*/, 'https://www.if-me.org$&', host: 'if-me.org')
end
-require ::File.expand_path('../config/environment', __FILE__)
+require File.expand_path('config/environment', __dir__)
run Rails.application