diff --git a/.erb-lint.yml b/.erb-lint.yml index 5c2007e61..5f48c3355 100644 --- a/.erb-lint.yml +++ b/.erb-lint.yml @@ -1,5 +1,7 @@ --- linters: + ExtraNewline: + enabled: true FinalNewline: enabled: true SelfClosingTag: @@ -16,5 +18,27 @@ linters: enabled: true only: - Layout/EndOfLine + - Layout/SpaceAfterColon + - Layout/SpaceAfterComma + - Layout/SpaceAfterMethodName + - Layout/SpaceAfterNot + - Layout/SpaceAfterSemicolon + - Layout/SpaceAroundBlockParameters + - Layout/SpaceAroundOperators + - Layout/SpaceBeforeBlockBraces + - Layout/SpaceBeforeComma + - Layout/SpaceBeforeComment + - Layout/SpaceBeforeFirstArg + - Layout/SpaceBeforeSemicolon + - Layout/SpaceInsideArrayLiteralBrackets + - Layout/SpaceInsideArrayPercentLiteral + - Layout/SpaceInsideBlockBraces + - Layout/SpaceInsideHashLiteralBraces + - Layout/SpaceInsideParens + - Layout/SpaceInsidePercentLiteralDelimiters + - Layout/SpaceInsideRangeLiteral + - Layout/SpaceInsideReferenceBrackets + - Layout/SpaceInsideStringInterpolation + - Layout/Tab - Lint/LiteralAsCondition - Style/PercentLiteralDelimiters diff --git a/.rubocop_basic.yml b/.rubocop_basic.yml index d264ee91c..62496d567 100644 --- a/.rubocop_basic.yml +++ b/.rubocop_basic.yml @@ -32,6 +32,73 @@ Layout/EmptyLines: Layout/EndOfLine: EnforcedStyle: lf +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterMethodName: + Enabled: true + +Layout/SpaceAfterNot: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundBlockParameters: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeBlockBraces: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeComment: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Layout/SpaceBeforeSemicolon: + Enabled: true + +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true + +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true + +Layout/SpaceInsideBlockBraces: + Enabled: true + +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + EnforcedStyle: compact + +Layout/SpaceInsideParens: + Enabled: true + +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: true + +Layout/SpaceInsideRangeLiteral: + Enabled: true + +Layout/SpaceInsideReferenceBrackets: + Enabled: true + +Layout/SpaceInsideStringInterpolation: + Enabled: true + +Layout/Tab: + Enabled: true + Layout/TrailingBlankLines: Enabled: true diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index aac0f979e..ce97a1bb5 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -81,7 +81,7 @@ class Admin::BudgetsController < Admin::BaseController private def budget_params - descriptions = Budget::Phase::PHASE_KINDS.map{|p| "description_#{p}"}.map(&:to_sym) + descriptions = Budget::Phase::PHASE_KINDS.map { |p| "description_#{p}" }.map(&:to_sym) valid_attributes = [:phase, :currency_symbol, :help_link, diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index 06c20711a..5f9c276b0 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -7,7 +7,7 @@ class Admin::CommentsController < Admin::BaseController respond_to do |format| format.html - format.csv {send_data to_csv(Comment.sort_by_newest, Comment), + format.csv { send_data to_csv(Comment.sort_by_newest, Comment), type: "text/csv", disposition: "attachment", filename: "comments.csv" } diff --git a/app/controllers/admin/dashboard/administrator_tasks_controller.rb b/app/controllers/admin/dashboard/administrator_tasks_controller.rb index 88e77153e..df4b13aef 100644 --- a/app/controllers/admin/dashboard/administrator_tasks_controller.rb +++ b/app/controllers/admin/dashboard/administrator_tasks_controller.rb @@ -17,7 +17,7 @@ class Admin::Dashboard::AdministratorTasksController < Admin::Dashboard::BaseCon administrator_task.update(user: current_user, executed_at: Time.current) redirect_to admin_dashboard_administrator_tasks_path, - { flash: { notice: t("admin.dashboard.administrator_tasks.update.success") } } + { flash: { notice: t("admin.dashboard.administrator_tasks.update.success") }} end private diff --git a/app/controllers/admin/download_settings_controller.rb b/app/controllers/admin/download_settings_controller.rb index 2c8b50789..15c3bf06e 100644 --- a/app/controllers/admin/download_settings_controller.rb +++ b/app/controllers/admin/download_settings_controller.rb @@ -4,7 +4,7 @@ class Admin::DownloadSettingsController < Admin::BaseController load_and_authorize_resource def edit - permitted = downloadable_params + permitted = downloadable_params @download_settings = [] if permitted_models.include? permitted[:resource] set_edit(permitted[:resource]) @@ -12,7 +12,7 @@ class Admin::DownloadSettingsController < Admin::BaseController end def update - permitted = downloadable_params + permitted = downloadable_params if permitted[:downloadable] DownloadSetting.where(name_model: get_model(permitted[:resource]).to_s, config: permitted[:config].to_i).each do |download_setting| @@ -27,7 +27,7 @@ class Admin::DownloadSettingsController < Admin::BaseController private def set_edit(resource) - @download_resource = {name: resource, config: get_config} + @download_resource = { name: resource, config: get_config } @download_settings = get_attrs(get_model(resource), get_config) end diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 053017644..ae1cea8a0 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -12,7 +12,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll .page(params[:page]) respond_to do |format| format.html - format.csv {send_data to_csv(process_for_download, Legislation::Process), + format.csv { send_data to_csv(process_for_download, Legislation::Process), type: "text/csv", disposition: "attachment", filename: "legislation_processes.csv" } diff --git a/app/controllers/admin/local_census_records/imports_controller.rb b/app/controllers/admin/local_census_records/imports_controller.rb index 4d450842d..19d7abca5 100644 --- a/app/controllers/admin/local_census_records/imports_controller.rb +++ b/app/controllers/admin/local_census_records/imports_controller.rb @@ -4,7 +4,7 @@ class Admin::LocalCensusRecords::ImportsController < Admin::LocalCensusRecords:: def create @import = LocalCensusRecords::Import.new(local_census_records_import_params) if @import.save - flash.now[:notice] = t("admin.local_census_records.imports.create.notice") + flash.now[:notice] = t("admin.local_census_records.imports.create.notice") render :show else render :new diff --git a/app/controllers/admin/poll/booth_assignments_controller.rb b/app/controllers/admin/poll/booth_assignments_controller.rb index 7ddf01b1e..13a6955c9 100644 --- a/app/controllers/admin/poll/booth_assignments_controller.rb +++ b/app/controllers/admin/poll/booth_assignments_controller.rb @@ -18,7 +18,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController def show included_relations = [:recounts, :voters, officer_assignments: [officer: [:user]]] @booth_assignment = @poll.booth_assignments.includes(*included_relations).find(params[:id]) - @voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date} + @voters_by_date = @booth_assignment.voters.group_by { |v| v.created_at.to_date } @partial_results = @booth_assignment.partial_results @recounts = @booth_assignment.recounts end diff --git a/app/controllers/admin/site_customization/images_controller.rb b/app/controllers/admin/site_customization/images_controller.rb index ccca12477..149b5f489 100644 --- a/app/controllers/admin/site_customization/images_controller.rb +++ b/app/controllers/admin/site_customization/images_controller.rb @@ -18,7 +18,7 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas flash.now[:error] = t("admin.site_customization.images.update.error") @images = SiteCustomization::Image.all_images - idx = @images.index {|e| e.name == @image.name } + idx = @images.index { |e| e.name == @image.name } @images[idx] = @image render :index diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index 314280db8..29ff8db6a 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -77,13 +77,13 @@ class Admin::StatsController < Admin::BaseController authorize! :read_admin_stats, @budget, message: t("admin.stats.budgets.no_data_before_balloting_phase") - @user_count = @budget.ballots.select {|ballot| ballot.lines.any? }.count + @user_count = @budget.ballots.select { |ballot| ballot.lines.any? }.count @vote_count = @budget.lines.count - @vote_count_by_heading = @budget.lines.group(:heading_id).count.collect {|k,v| [Budget::Heading.find(k).name, v]}.sort + @vote_count_by_heading = @budget.lines.group(:heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort - @user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect {|k,v| [Budget::Heading.find(k).name, v]}.sort + @user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort end def polls diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 18127079b..74414293f 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -98,7 +98,7 @@ module Budgets end def json_data - investment = Budget::Investment.find(params[:id]) + investment = Budget::Investment.find(params[:id]) data = { investment_id: investment.id, investment_title: investment.title, diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb index bb610d4a6..ffebce26d 100644 --- a/app/controllers/concerns/commentable_actions.rb +++ b/app/controllers/concerns/commentable_actions.rb @@ -28,7 +28,7 @@ module CommentableActions respond_to do |format| format.html - format.csv {send_data to_csv(resources_csv, resource_model), + format.csv { send_data to_csv(resources_csv, resource_model), type: "text/csv", disposition: "attachment", filename: "#{get_resource(resource_model)}.csv" } diff --git a/app/controllers/concerns/dashboard/group_supports.rb b/app/controllers/concerns/dashboard/group_supports.rb index d96de70e9..c5fbf6b3a 100644 --- a/app/controllers/concerns/dashboard/group_supports.rb +++ b/app/controllers/concerns/dashboard/group_supports.rb @@ -60,7 +60,7 @@ module Dashboard::GroupSupports end def calculate_year_of_week(date) - year = date.year + year = date.year if first_week_of_year?(date) && date.end_of_week.year != date.year year = year + 1 elsif last_week_of_year?(date) && date.beginning_of_week.year != date.year diff --git a/app/controllers/concerns/moderate_actions.rb b/app/controllers/concerns/moderate_actions.rb index 98e67bc2b..f8c2b96c8 100644 --- a/app/controllers/concerns/moderate_actions.rb +++ b/app/controllers/concerns/moderate_actions.rb @@ -19,14 +19,14 @@ module ModerateActions @resources = @resources.where(id: params[:resource_ids]) if params[:hide_resources].present? - @resources.accessible_by(current_ability, :hide).each {|resource| hide_resource resource} + @resources.accessible_by(current_ability, :hide).each { |resource| hide_resource resource } elsif params[:ignore_flags].present? @resources.accessible_by(current_ability, :ignore_flag).each(&:ignore_flag) elsif params[:block_authors].present? author_ids = @resources.pluck(author_id).uniq - User.where(id: author_ids).accessible_by(current_ability, :block).each {|user| block_user user} + User.where(id: author_ids).accessible_by(current_ability, :block).each { |user| block_user user } end redirect_to request.query_parameters.merge(action: :index) diff --git a/app/controllers/dashboard/actions_controller.rb b/app/controllers/dashboard/actions_controller.rb index 6ef73265e..01cbfd913 100644 --- a/app/controllers/dashboard/actions_controller.rb +++ b/app/controllers/dashboard/actions_controller.rb @@ -20,7 +20,7 @@ class Dashboard::ActionsController < Dashboard::BaseController Dashboard::AdministratorTask.create(source: @dashboard_executed_action) redirect_to progress_proposal_dashboard_path(proposal.to_param), - { flash: { info: t("dashboard.create_request.success") } } + { flash: { info: t("dashboard.create_request.success") }} else flash.now[:alert] = @dashboard_executed_action.errors.full_messages.join("
") render :new_request diff --git a/app/controllers/direct_uploads_controller.rb b/app/controllers/direct_uploads_controller.rb index 5b19977f7..d1d52eb4c 100644 --- a/app/controllers/direct_uploads_controller.rb +++ b/app/controllers/direct_uploads_controller.rb @@ -18,7 +18,7 @@ class DirectUploadsController < ApplicationController render json: { cached_attachment: @direct_upload.relation.cached_attachment, filename: @direct_upload.relation.attachment.original_filename, destroy_link: render_destroy_upload_link(@direct_upload).html_safe, - attachment_url: @direct_upload.relation.attachment.url} + attachment_url: @direct_upload.relation.attachment.url } else @direct_upload.destroy_attachment render json: { errors: @direct_upload.errors[:attachment].join(", ") }, diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb index c450963e4..7356d91f8 100644 --- a/app/controllers/legislation/processes_controller.rb +++ b/app/controllers/legislation/processes_controller.rb @@ -111,7 +111,7 @@ class Legislation::ProcessesController < Legislation::BaseController @phase = :resume respond_to do |format| format.html - format.xlsx {render xlsx: "resume_to_xlsx", filename: ("resume-" + Date.current.to_s + ".xlsx")} + format.xlsx { render xlsx: "resume_to_xlsx", filename: ("resume-" + Date.current.to_s + ".xlsx") } end end diff --git a/app/controllers/management/sessions_controller.rb b/app/controllers/management/sessions_controller.rb index 83e364e00..49784c53e 100644 --- a/app/controllers/management/sessions_controller.rb +++ b/app/controllers/management/sessions_controller.rb @@ -28,13 +28,13 @@ class Management::SessionsController < ActionController::Base def admin? if current_user.try(:administrator?) - session[:manager] = {login: "admin_user_#{current_user.id}"} + session[:manager] = { login: "admin_user_#{current_user.id}" } end end def manager? if current_user.try(:manager?) - session[:manager] = {login: "manager_user_#{current_user.id}"} + session[:manager] = { login: "manager_user_#{current_user.id}" } end end diff --git a/app/controllers/officing/polls_controller.rb b/app/controllers/officing/polls_controller.rb index dc806d35f..69bc9eb64 100644 --- a/app/controllers/officing/polls_controller.rb +++ b/app/controllers/officing/polls_controller.rb @@ -3,7 +3,7 @@ class Officing::PollsController < Officing::BaseController def index @polls = current_user.poll_officer? ? current_user.poll_officer.voting_days_assigned_polls : [] - @polls = @polls.select {|poll| poll.current?(Time.current) || poll.current?(1.day.ago)} + @polls = @polls.select { |poll| poll.current?(Time.current) || poll.current?(1.day.ago) } end def final diff --git a/app/controllers/polls/answers_controller.rb b/app/controllers/polls/answers_controller.rb index 49c5fcfc9..61b3b33d3 100644 --- a/app/controllers/polls/answers_controller.rb +++ b/app/controllers/polls/answers_controller.rb @@ -19,7 +19,7 @@ class Polls::AnswersController < ApplicationController load_for_answers if @question.enum_type&.include?("answer_couples") last_pair ||= generate_and_store_new_pair(@question) - @last_pair_question_answers = {@question.id => last_pair} + @last_pair_question_answers = { @question.id => last_pair } end render "polls/questions/answer", format: :js end @@ -34,7 +34,7 @@ class Polls::AnswersController < ApplicationController load_for_answers if @question.enum_type&.include?("answer_couples") last_pair ||= generate_and_store_new_pair(@question) - @last_pair_question_answers = {@question.id => last_pair} + @last_pair_question_answers = { @question.id => last_pair } end render "polls/questions/answer", format: :js end @@ -53,10 +53,10 @@ class Polls::AnswersController < ApplicationController def load_for_answers @page = params[:page].present? ? params[:page] : 1 question_answers - @answers_by_question_id = {@question.id => @question.answers + @answers_by_question_id = { @question.id => @question.answers .by_author(current_user) .order(:order) - .pluck(:answer)} + .pluck(:answer) } end def question_answers diff --git a/app/controllers/polls/questions_controller.rb b/app/controllers/polls/questions_controller.rb index b929e0fc5..d1ad187da 100644 --- a/app/controllers/polls/questions_controller.rb +++ b/app/controllers/polls/questions_controller.rb @@ -11,7 +11,7 @@ class Polls::QuestionsController < ApplicationController load_for_answers if @question.enum_type&.include?("answer_couples") last_pair ||= generate_and_store_new_pair(@question) - @last_pair_question_answers = {@question.id => last_pair} + @last_pair_question_answers = { @question.id => last_pair } end end @@ -39,10 +39,10 @@ class Polls::QuestionsController < ApplicationController def load_for_answers @page = params[:page].present? ? params[:page] : 1 question_answers - @answers_by_question_id = {@question.id => @question.answers + @answers_by_question_id = { @question.id => @question.answers .by_author(current_user) .order(:order) - .pluck(:answer)} + .pluck(:answer) } end def vote_stored(answer, new_answer, token) diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 6f35d44be..1b3bcfda6 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -98,7 +98,7 @@ class ProposalsController < ApplicationController private def proposal_params - attributes = [:video_url,:responsible_name, :tag_list, + attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id, :skip_map, image_attributes: image_attributes, documents_attributes: [:id, :title, :attachment, :cached_attachment, diff --git a/app/controllers/remote_translations_controller.rb b/app/controllers/remote_translations_controller.rb index d811d2f5c..f7bdc99e2 100644 --- a/app/controllers/remote_translations_controller.rb +++ b/app/controllers/remote_translations_controller.rb @@ -20,7 +20,7 @@ class RemoteTranslationsController < ApplicationController def set_remote_translations remote_translations = remote_translations_params["remote_translations"] decoded_remote_translations = ActiveSupport::JSON.decode(remote_translations) - @remote_translations = decoded_remote_translations.map{ |remote_translation| + @remote_translations = decoded_remote_translations.map { |remote_translation| remote_translation.slice("remote_translatable_id", "remote_translatable_type", "locale") diff --git a/app/controllers/tracking/budget_investments_controller.rb b/app/controllers/tracking/budget_investments_controller.rb index 946f61143..d588964ec 100644 --- a/app/controllers/tracking/budget_investments_controller.rb +++ b/app/controllers/tracking/budget_investments_controller.rb @@ -63,7 +63,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController filters << { name: heading.name, id: heading.id, - count: investments.select{|i| i.heading_id == heading.id}.size + count: investments.select { |i| i.heading_id == heading.id }.size } end filters.uniq diff --git a/app/controllers/tracking/proposal_progress_bars_controller.rb b/app/controllers/tracking/proposal_progress_bars_controller.rb index 6d1c597b4..46d43474a 100644 --- a/app/controllers/tracking/proposal_progress_bars_controller.rb +++ b/app/controllers/tracking/proposal_progress_bars_controller.rb @@ -1,4 +1,4 @@ -class Tracking::ProposalProgressBarsController < Tracking::ProgressBarsController +class Tracking::ProposalProgressBarsController < Tracking::ProgressBarsController private def progressable diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 3ffced63e..187b05e5f 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -19,7 +19,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController end else resource.errors.add(:email, :password_already_set) - respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } + respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new } end end @@ -33,14 +33,14 @@ class Users::ConfirmationsController < Devise::ConfirmationsController # New condition added to if: when no password was given, display the "show" view (which uses "update" above) if resource.encrypted_password.blank? - respond_with_navigational(resource){ render :show } + respond_with_navigational(resource) { render :show } elsif resource.errors.empty? set_official_position if resource.has_official_email? resource.confirm # Last change: confirm happens here for people with passwords instead of af the top of the show action set_flash_message(:notice, :confirmed) if is_flashing_format? - respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } + respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) } else - respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } + respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new } end end diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 0270b36c7..cb5e256af 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -50,9 +50,9 @@ class Users::RegistrationsController < Devise::RegistrationsController def check_username if User.find_by username: params[:username] - render json: {available: false, message: t("devise_views.users.registrations.new.username_is_not_available")} + render json: { available: false, message: t("devise_views.users.registrations.new.username_is_not_available") } else - render json: {available: true, message: t("devise_views.users.registrations.new.username_is_available")} + render json: { available: true, message: t("devise_views.users.registrations.new.username_is_available") } end end diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb index 6c33a2766..73324a0a4 100644 --- a/app/controllers/valuation/budget_investments_controller.rb +++ b/app/controllers/valuation/budget_investments_controller.rb @@ -89,7 +89,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController filters << { name: heading.name, id: heading.id, - count: investments.select{|i| i.heading_id == heading.id}.size + count: investments.select { |i| i.heading_id == heading.id }.size } end end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index f3b8d7b90..9f3a21c7e 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -85,7 +85,7 @@ module AdminHelper def admin_select_options Administrator.with_user - .collect { |v| [ v.description_or_name, v.id ] } + .collect { |v| [v.description_or_name, v.id] } .sort_by { |a| a[0] } end diff --git a/app/helpers/budget_executions_helper.rb b/app/helpers/budget_executions_helper.rb index d8f20936f..ee6d286ab 100644 --- a/app/helpers/budget_executions_helper.rb +++ b/app/helpers/budget_executions_helper.rb @@ -12,7 +12,7 @@ module BudgetExecutionsHelper def first_milestone_with_image(investment) investment.milestones.order_by_publication_date - .select{ |milestone| milestone.image.present? }.last + .select { |milestone| milestone.image.present? }.last end end diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 622cfcb4d..14ce89af8 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -19,11 +19,11 @@ module BudgetsHelper end def budget_phases_select_options - Budget::Phase::PHASE_KINDS.map { |ph| [ t("budgets.phase.#{ph}"), ph ] } + Budget::Phase::PHASE_KINDS.map { |ph| [t("budgets.phase.#{ph}"), ph] } end def budget_currency_symbol_select_options - Budget::CURRENCY_SYMBOLS.map { |cs| [ cs, cs ] } + Budget::CURRENCY_SYMBOLS.map { |cs| [cs, cs] } end def namespaced_budget_investment_path(investment, options = {}) diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index b0facdacc..f445679a1 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -27,7 +27,7 @@ module DocumentsHelper remote: true, class: "delete remove-cached-attachment" else - link_to_remove_association document.new_record? ? t("documents.form.cancel_button") : t("documents.form.delete_button") , builder, class: "delete remove-document" + link_to_remove_association document.new_record? ? t("documents.form.cancel_button") : t("documents.form.delete_button"), builder, class: "delete remove-document" end end diff --git a/app/helpers/followables_helper.rb b/app/helpers/followables_helper.rb index bf6cbd8f6..80292c8c3 100644 --- a/app/helpers/followables_helper.rb +++ b/app/helpers/followables_helper.rb @@ -16,7 +16,7 @@ module FollowablesHelper followable = follow.followable partial = followable_class_name(followable) + "_follow" - locals = {followable_class_name(followable).to_sym => followable} + locals = { followable_class_name(followable).to_sym => followable } render partial, locals end diff --git a/app/helpers/geozones_helper.rb b/app/helpers/geozones_helper.rb index bfc5f9105..c898760bf 100644 --- a/app/helpers/geozones_helper.rb +++ b/app/helpers/geozones_helper.rb @@ -5,7 +5,7 @@ module GeozonesHelper end def geozone_select_options - Geozone.all.order(name: :asc).collect { |g| [ g.name, g.id ] } + Geozone.all.order(name: :asc).collect { |g| [g.name, g.id] } end end diff --git a/app/helpers/globalize_helper.rb b/app/helpers/globalize_helper.rb index 65021b350..4d659919b 100644 --- a/app/helpers/globalize_helper.rb +++ b/app/helpers/globalize_helper.rb @@ -5,8 +5,8 @@ module GlobalizeHelper end def available_locales(resource) - I18n.available_locales.select{ |locale| enabled_locale?(resource, locale) }.map do |locale| - [name_for_locale(locale), locale , { data: { locale: locale } }] + I18n.available_locales.select { |locale| enabled_locale?(resource, locale) }.map do |locale| + [name_for_locale(locale), locale, { data: { locale: locale }}] end end diff --git a/app/helpers/imageables_helper.rb b/app/helpers/imageables_helper.rb index 7c8d87298..520041778 100644 --- a/app/helpers/imageables_helper.rb +++ b/app/helpers/imageables_helper.rb @@ -17,7 +17,7 @@ module ImageablesHelper end def imageable_accepted_content_types - Setting["uploads.images.content_types"]&.split(" ") || [ "image/jpeg" ] + Setting["uploads.images.content_types"]&.split(" ") || ["image/jpeg"] end def imageable_accepted_content_types_extensions diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index 3d53acf6d..184ad9751 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -5,7 +5,7 @@ module OfficingHelper officer_assignments.each do |oa| options << [oa.booth_assignment.booth.name.to_s, oa.id] end - options.sort! {|x, y| x[0] <=> y[0]} + options.sort! { |x, y| x[0] <=> y[0] } options_for_select(options, params[:oa]) end diff --git a/app/helpers/proposals_dashboard_helper.rb b/app/helpers/proposals_dashboard_helper.rb index b7abee430..576473b93 100644 --- a/app/helpers/proposals_dashboard_helper.rb +++ b/app/helpers/proposals_dashboard_helper.rb @@ -108,7 +108,7 @@ module ProposalsDashboardHelper def new_resources_since_last_login?(resources, new_actions_since_last_login) if resources.present? - resources.pluck(:id).any? {|id| new_actions_since_last_login.include?(id) } + resources.pluck(:id).any? { |id| new_actions_since_last_login.include?(id) } end end diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 3879d4679..ff8659dd2 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -29,7 +29,7 @@ module ProposalsHelper end def retire_proposals_options - Proposal::RETIRE_OPTIONS.collect { |option| [ t("proposals.retire_options.#{option}"), option ] } + Proposal::RETIRE_OPTIONS.collect { |option| [t("proposals.retire_options.#{option}"), option] } end def empty_recommended_proposals_message_text(user) diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index b38048fb1..fed7454fe 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,7 +1,7 @@ module SearchHelper def official_level_search_options - options_for_select((1..5).map{ |i| [setting["official_level_#{i}_name"], i] }, + options_for_select((1..5).map { |i| [setting["official_level_#{i}_name"], i] }, params[:advanced_search].try(:[], :official_level)) end diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index 018189394..5d9ee2ebe 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -5,7 +5,7 @@ module SettingsHelper end def setting - @all_settings ||= Hash[ Setting.all.map{|s| [s.key, s.value.presence]} ] + @all_settings ||= Hash[Setting.all.map { |s| [s.key, s.value.presence] }] end def display_setting_name(setting_name) diff --git a/app/helpers/valuation_helper.rb b/app/helpers/valuation_helper.rb index 9f2f27528..a0ba66e3a 100644 --- a/app/helpers/valuation_helper.rb +++ b/app/helpers/valuation_helper.rb @@ -6,11 +6,11 @@ module ValuationHelper def valuator_select_options Valuator.order("description ASC").order("users.email ASC").includes(:user). - collect { |v| [ v.description_or_email, "valuator_#{v.id}"] } + collect { |v| [v.description_or_email, "valuator_#{v.id}"] } end def valuator_group_select_options - ValuatorGroup.order("name ASC").collect { |g| [ g.name, "group_#{g.id}"] } + ValuatorGroup.order("name ASC").collect { |g| [g.name, "group_#{g.id}"] } end def assigned_valuators_info(valuators) diff --git a/app/helpers/valuators_helper.rb b/app/helpers/valuators_helper.rb index 616cb6fef..0d9d1d715 100644 --- a/app/helpers/valuators_helper.rb +++ b/app/helpers/valuators_helper.rb @@ -5,7 +5,7 @@ module ValuatorsHelper end def valuator_abilities(valuator) - [ valuator.can_comment ? I18n.t("admin.valuators.index.can_comment") : nil , + [valuator.can_comment ? I18n.t("admin.valuators.index.can_comment") : nil, valuator.can_edit_dossier ? I18n.t("admin.valuators.index.can_edit_dossier") : nil ].compact.join(", ") end diff --git a/app/helpers/votes_helper.rb b/app/helpers/votes_helper.rb index 4255b7656..946b9bf7c 100644 --- a/app/helpers/votes_helper.rb +++ b/app/helpers/votes_helper.rb @@ -16,11 +16,11 @@ module VotesHelper def css_classes_for_vote(votes, votable) case votes[votable.id] when true - {in_favor: "voted", against: "no-voted"} + { in_favor: "voted", against: "no-voted" } when false - {in_favor: "no-voted", against: "voted"} + { in_favor: "no-voted", against: "voted" } else - {in_favor: "", against: ""} + { in_favor: "", against: "" } end end diff --git a/app/models/abilities/moderation.rb b/app/models/abilities/moderation.rb index 86f44f25e..51ffee7b0 100644 --- a/app/models/abilities/moderation.rb +++ b/app/models/abilities/moderation.rb @@ -6,8 +6,8 @@ module Abilities merge Abilities::Common.new(user) can :read, Organization - can(:verify, Organization){ |o| !o.verified? } - can(:reject, Organization){ |o| !o.rejected? } + can(:verify, Organization) { |o| !o.verified? } + can(:reject, Organization) { |o| !o.rejected? } can :read, Comment diff --git a/app/models/activity.rb b/app/models/activity.rb index 1bc3851b8..b356d637c 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -4,7 +4,7 @@ class Activity < ApplicationRecord VALID_ACTIONS = %w[hide block restore valuate email] - validates :action, inclusion: {in: VALID_ACTIONS} + validates :action, inclusion: { in: VALID_ACTIONS } scope :on_proposals, -> { where(actionable_type: "Proposal") } scope :on_debates, -> { where(actionable_type: "Debate") } diff --git a/app/models/ahoy/data_source.rb b/app/models/ahoy/data_source.rb index 78c228fc4..7f68155e9 100644 --- a/app/models/ahoy/data_source.rb +++ b/app/models/ahoy/data_source.rb @@ -10,7 +10,7 @@ module Ahoy # chart def add(name, collection) collections.push data: collection, name: name - collection.each_key{ |key| add_key key } + collection.each_key { |key| add_key key } end def build diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index aa83a499a..935d33a17 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -44,8 +44,8 @@ class Budget has_many :valuator_group_assignments, dependent: :destroy has_many :valuator_groups, through: :valuator_group_assignments - has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: "Comment" - has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: "Comment" + has_many :comments, -> { where(valuation: false) }, as: :commentable, class_name: "Comment" + has_many :valuations, -> { where(valuation: true) }, as: :commentable, class_name: "Comment" has_many :tracker_assignments, dependent: :destroy has_many :trackers, through: :tracker_assignments @@ -74,7 +74,7 @@ class Budget scope :without_valuator, -> { valuation_open.without_valuator_group.where(valuator_assignments_count: 0) } scope :under_valuation, -> { valuation_open.valuating.where("administrator_id IS NOT ?", nil) } scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).where("administrator_id IS NOT ?", nil) } - scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 OR valuator_group_assignments_count > 0" ) } + scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 OR valuator_group_assignments_count > 0") } scope :visible_to_valuators, -> { where(visible_to_valuators: true) } scope :valuation_finished, -> { where(valuation_finished: true) } scope :valuation_finished_feasible, -> { where(valuation_finished: true, feasibility: "feasible") } @@ -88,7 +88,7 @@ class Budget scope :incompatible, -> { where(incompatible: true) } scope :winners, -> { selected.compatible.where(winner: true) } scope :unselected, -> { not_unfeasible.where(selected: false) } - scope :last_week, -> { where("created_at >= ?", 7.days.ago)} + scope :last_week, -> { where("created_at >= ?", 7.days.ago) } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) } diff --git a/app/models/budget/reclassified_vote.rb b/app/models/budget/reclassified_vote.rb index 6b3ad99d8..1e9053428 100644 --- a/app/models/budget/reclassified_vote.rb +++ b/app/models/budget/reclassified_vote.rb @@ -7,6 +7,6 @@ class Budget validates :user, presence: true validates :investment, presence: true - validates :reason, inclusion: {in: REASONS, allow_nil: false} + validates :reason, inclusion: { in: REASONS, allow_nil: false } end end diff --git a/app/models/budget/stats.rb b/app/models/budget/stats.rb index cd9bff741..4b20e7175 100644 --- a/app/models/budget/stats.rb +++ b/app/models/budget/stats.rb @@ -72,18 +72,18 @@ class Budget::Stats end groups[:total] = Hash.new(0) - groups[:total][:total_investments_count] = groups.collect {|_k, v| v[:total_investments_count]}.sum - groups[:total][:total_participants_support_phase] = groups.collect {|_k, v| v[:total_participants_support_phase]}.sum - groups[:total][:total_participants_vote_phase] = groups.collect {|_k, v| v[:total_participants_vote_phase]}.sum - groups[:total][:total_participants_every_phase] = groups.collect {|_k, v| v[:total_participants_every_phase]}.sum + groups[:total][:total_investments_count] = groups.collect { |_k, v| v[:total_investments_count] }.sum + groups[:total][:total_participants_support_phase] = groups.collect { |_k, v| v[:total_participants_support_phase] }.sum + groups[:total][:total_participants_vote_phase] = groups.collect { |_k, v| v[:total_participants_vote_phase] }.sum + groups[:total][:total_participants_every_phase] = groups.collect { |_k, v| v[:total_participants_every_phase] }.sum budget.headings.each do |heading| groups[heading.id].merge!(calculate_heading_stats_with_totals(groups[heading.id], groups[:total], heading.population)) end - groups[:total][:percentage_participants_support_phase] = groups.collect {|_k, v| v[:percentage_participants_support_phase]}.sum - groups[:total][:percentage_participants_vote_phase] = groups.collect {|_k, v| v[:percentage_participants_vote_phase]}.sum - groups[:total][:percentage_participants_every_phase] = groups.collect {|_k, v| v[:percentage_participants_every_phase]}.sum + groups[:total][:percentage_participants_support_phase] = groups.collect { |_k, v| v[:percentage_participants_support_phase] }.sum + groups[:total][:percentage_participants_vote_phase] = groups.collect { |_k, v| v[:percentage_participants_vote_phase] }.sum + groups[:total][:percentage_participants_every_phase] = groups.collect { |_k, v| v[:percentage_participants_every_phase] }.sum groups end @@ -125,7 +125,7 @@ class Budget::Stats def balloters_by_heading(heading_id) stats_cache("balloters_by_heading_#{heading_id}") do budget.ballots.joins(:lines) - .where(budget_ballot_lines: { heading_id: heading_id} ) + .where(budget_ballot_lines: { heading_id: heading_id }) .distinct.pluck(:user_id) end end diff --git a/app/models/concerns/documentable.rb b/app/models/concerns/documentable.rb index 9f49d9af9..eeaefc51b 100644 --- a/app/models/concerns/documentable.rb +++ b/app/models/concerns/documentable.rb @@ -16,7 +16,7 @@ module Documentable end def accepted_content_types - Setting["uploads.documents.content_types"]&.split(" ") || [ "application/pdf" ] + Setting["uploads.documents.content_types"]&.split(" ") || ["application/pdf"] end end diff --git a/app/models/concerns/download_settings/budget_investment_csv.rb b/app/models/concerns/download_settings/budget_investment_csv.rb index d257a899e..05ba06e3c 100644 --- a/app/models/concerns/download_settings/budget_investment_csv.rb +++ b/app/models/concerns/download_settings/budget_investment_csv.rb @@ -19,7 +19,7 @@ module DownloadSettings CSV.generate(options) do |csv| csv << attributes budgets.each do |budget| - csv << attributes.map{ |attr| budget.send(attr)} + csv << attributes.map { |attr| budget.send(attr) } end end end diff --git a/app/models/concerns/download_settings/comment_csv.rb b/app/models/concerns/download_settings/comment_csv.rb index 2226054a7..581bfaae9 100644 --- a/app/models/concerns/download_settings/comment_csv.rb +++ b/app/models/concerns/download_settings/comment_csv.rb @@ -19,7 +19,7 @@ module DownloadSettings CSV.generate(options) do |csv| csv << attributes comments.each do |comment| - csv << attributes.map {|attr| comment.send(attr)} + csv << attributes.map { |attr| comment.send(attr) } end end end diff --git a/app/models/concerns/download_settings/debate_csv.rb b/app/models/concerns/download_settings/debate_csv.rb index 79113f54d..71380596e 100644 --- a/app/models/concerns/download_settings/debate_csv.rb +++ b/app/models/concerns/download_settings/debate_csv.rb @@ -19,7 +19,7 @@ module DownloadSettings CSV.generate(options) do |csv| csv << attributes debates.each do |debate| - csv << attributes.map{ |attr| debate.send(attr)} + csv << attributes.map { |attr| debate.send(attr) } end end end diff --git a/app/models/concerns/download_settings/legislation_process_csv.rb b/app/models/concerns/download_settings/legislation_process_csv.rb index 175c998ce..d2b6fe7b5 100644 --- a/app/models/concerns/download_settings/legislation_process_csv.rb +++ b/app/models/concerns/download_settings/legislation_process_csv.rb @@ -19,7 +19,7 @@ module DownloadSettings CSV.generate(options) do |csv| csv << attributes processes.each do |process| - csv << attributes.map{ |attr| process.send(attr)} + csv << attributes.map { |attr| process.send(attr) } end end end diff --git a/app/models/concerns/download_settings/proposal_csv.rb b/app/models/concerns/download_settings/proposal_csv.rb index f15b26b82..ddb0969ea 100644 --- a/app/models/concerns/download_settings/proposal_csv.rb +++ b/app/models/concerns/download_settings/proposal_csv.rb @@ -19,7 +19,7 @@ module DownloadSettings CSV.generate(options) do |csv| csv << attributes proposals.each do |proposal| - csv << attributes.map {|attr| proposal.send(attr)} + csv << attributes.map { |attr| proposal.send(attr) } end end end diff --git a/app/models/concerns/followable.rb b/app/models/concerns/followable.rb index d635cadda..e3e926d3b 100644 --- a/app/models/concerns/followable.rb +++ b/app/models/concerns/followable.rb @@ -5,7 +5,7 @@ module Followable has_many :follows, as: :followable, dependent: :destroy has_many :followers, through: :follows, source: :user - scope :followed_by_user, ->(user){ + scope :followed_by_user, ->(user) { joins(:follows).where("follows.user_id = ?", user.id) } end diff --git a/app/models/concerns/globalizable.rb b/app/models/concerns/globalizable.rb index 9999e3502..3b683c912 100644 --- a/app/models/concerns/globalizable.rb +++ b/app/models/concerns/globalizable.rb @@ -22,18 +22,18 @@ module Globalizable end def locales_persisted_and_marked_for_destruction - translations.select{|t| t.persisted? && t.marked_for_destruction? }.map(&:locale) + translations.select { |t| t.persisted? && t.marked_for_destruction? }.map(&:locale) end def translations_required? - translated_attribute_names.any?{|attr| required_attribute?(attr)} + translated_attribute_names.any? { |attr| required_attribute?(attr) } end if self.paranoid? && translation_class.attribute_names.include?("hidden_at") translation_class.send :acts_as_paranoid, column: :hidden_at end - scope :with_translation, -> { joins("LEFT OUTER JOIN #{translations_table_name} ON #{table_name}.id = #{translations_table_name}.#{reflections["translations"].foreign_key} AND #{translations_table_name}.locale='#{I18n.locale }'") } + scope :with_translation, -> { joins("LEFT OUTER JOIN #{translations_table_name} ON #{table_name}.id = #{translations_table_name}.#{reflections["translations"].foreign_key} AND #{translations_table_name}.locale='#{I18n.locale}'") } private @@ -41,7 +41,7 @@ module Globalizable presence_validators = [ActiveModel::Validations::PresenceValidator, ActiveRecord::Validations::PresenceValidator] - attribute_validators(attribute).any?{|validator| presence_validators.include? validator } + attribute_validators(attribute).any? { |validator| presence_validators.include? validator } end def attribute_validators(attribute) diff --git a/app/models/concerns/search_cache.rb b/app/models/concerns/search_cache.rb index fd01c98a0..c78e8643d 100644 --- a/app/models/concerns/search_cache.rb +++ b/app/models/concerns/search_cache.rb @@ -14,8 +14,8 @@ module SearchCache def searchable_values_sql searchable_values - .select{ |k, _| k.present? } - .collect{ |value, weight| set_tsvector(value, weight) } + .select { |k, _| k.present? } + .collect { |value, weight| set_tsvector(value, weight) } .join(" || ") end diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/taggable.rb index 57a30414d..c840dd97e 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/taggable.rb @@ -9,7 +9,7 @@ module Taggable def tag_list_with_limit(limit = nil) return tags if limit.blank? - tags.sort{|a, b| b.taggings_count <=> a.taggings_count}[0, limit] + tags.sort { |a, b| b.taggings_count <=> a.taggings_count }[0, limit] end def tags_count_out_of_limit(limit = nil) diff --git a/app/models/debate.rb b/app/models/debate.rb index 152059eaf..375f79c5f 100644 --- a/app/models/debate.rb +++ b/app/models/debate.rb @@ -47,8 +47,8 @@ class Debate < ApplicationRecord scope :sort_by_relevance, -> { all } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } scope :sort_by_recommendations, -> { order(cached_votes_total: :desc) } - scope :last_week, -> { where("created_at >= ?", 7.days.ago)} - scope :featured, -> { where("featured_at is not null")} + scope :last_week, -> { where("created_at >= ?", 7.days.ago) } + scope :featured, -> { where("featured_at is not null") } scope :public_for_api, -> { all } # Ahoy setup @@ -149,11 +149,11 @@ class Debate < ApplicationRecord end def after_hide - tags.each{ |t| t.decrement_custom_counter_for("Debate") } + tags.each { |t| t.decrement_custom_counter_for("Debate") } end def after_restore - tags.each{ |t| t.increment_custom_counter_for("Debate") } + tags.each { |t| t.increment_custom_counter_for("Debate") } end def featured? diff --git a/app/models/legislation/annotation.rb b/app/models/legislation/annotation.rb index 93a6c1acf..aa5b95006 100644 --- a/app/models/legislation/annotation.rb +++ b/app/models/legislation/annotation.rb @@ -35,8 +35,8 @@ class Legislation::Annotation < ApplicationRecord selector_end = "/html/body/#{range_end}" el_end = doc.at_xpath(selector_end) - remainder_el_start = el_start.text[0 .. range_start_offset - 1] unless range_start_offset.zero? - remainder_el_end = el_end.text[range_end_offset .. -1] + remainder_el_start = el_start.text[0..range_start_offset - 1] unless range_start_offset.zero? + remainder_el_end = el_end.text[range_end_offset..-1] self.context = "#{remainder_el_start}#{quote}#{remainder_el_end}" rescue diff --git a/app/models/legislation/answer.rb b/app/models/legislation/answer.rb index 3bf052167..22b901991 100644 --- a/app/models/legislation/answer.rb +++ b/app/models/legislation/answer.rb @@ -8,7 +8,7 @@ class Legislation::Answer < ApplicationRecord inverse_of: :answers, counter_cache: true belongs_to :user, dependent: :destroy, inverse_of: :legislation_answers - validates :question, presence: true, uniqueness: { scope: :user_id} + validates :question, presence: true, uniqueness: { scope: :user_id } validates :question_option, presence: true validates :user, presence: true end diff --git a/app/models/legislation/people_proposal.rb b/app/models/legislation/people_proposal.rb index ed57bf352..69696bb05 100644 --- a/app/models/legislation/people_proposal.rb +++ b/app/models/legislation/people_proposal.rb @@ -46,7 +46,7 @@ class Legislation::PeopleProposal < ApplicationRecord scope :sort_by_id, -> { reorder(id: :asc) } scope :sort_by_supports, -> { reorder(cached_votes_score: :desc) } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - scope :last_week, -> { where("people_proposals.created_at >= ?", 7.days.ago)} + scope :last_week, -> { where("people_proposals.created_at >= ?", 7.days.ago) } scope :validated, -> { where(validated: true) } scope :selected, -> { where(selected: true) } scope :winners, -> { selected.sort_by_confidence_score } @@ -60,7 +60,7 @@ class Legislation::PeopleProposal < ApplicationRecord author.username => "B", tag_list.join(" ") => "B", summary => "C", - description => "D"} + description => "D" } end def self.search(terms) @@ -131,11 +131,11 @@ class Legislation::PeopleProposal < ApplicationRecord end def after_hide - tags.each{ |t| t.decrement_custom_counter_for("LegislationPeopleProposal") } + tags.each { |t| t.decrement_custom_counter_for("LegislationPeopleProposal") } end def after_restore - tags.each{ |t| t.increment_custom_counter_for("LegislationPeopleProposal") } + tags.each { |t| t.increment_custom_counter_for("LegislationPeopleProposal") } end def contact_info diff --git a/app/models/legislation/proposal.rb b/app/models/legislation/proposal.rb index 879eeb27d..aa8a686b7 100644 --- a/app/models/legislation/proposal.rb +++ b/app/models/legislation/proposal.rb @@ -47,7 +47,7 @@ class Legislation::Proposal < ApplicationRecord scope :sort_by_id, -> { reorder(id: :asc) } scope :sort_by_supports, -> { reorder(cached_votes_score: :desc) } scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } - scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} + scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) } scope :selected, -> { where(selected: true) } scope :winners, -> { selected.sort_by_confidence_score } @@ -61,7 +61,7 @@ class Legislation::Proposal < ApplicationRecord tag_list.join(" ") => "B", geozone.try(:name) => "B", summary => "C", - description => "D"} + description => "D" } end def self.search(terms) @@ -132,11 +132,11 @@ class Legislation::Proposal < ApplicationRecord end def after_hide - tags.each{ |t| t.decrement_custom_counter_for("LegislationProposal") } + tags.each { |t| t.decrement_custom_counter_for("LegislationProposal") } end def after_restore - tags.each{ |t| t.increment_custom_counter_for("LegislationProposal") } + tags.each { |t| t.increment_custom_counter_for("LegislationProposal") } end protected diff --git a/app/models/local_census_records/import.rb b/app/models/local_census_records/import.rb index 70a48737d..c601ce9b3 100644 --- a/app/models/local_census_records/import.rb +++ b/app/models/local_census_records/import.rb @@ -68,8 +68,8 @@ class LocalCensusRecords::Import def file_headers_definition headers = fetch_file_headers - return if headers.all? {|header| ATTRIBUTES.include? header } && - ATTRIBUTES.all? {|attr| headers.include? attr } + return if headers.all? { |header| ATTRIBUTES.include? header } && + ATTRIBUTES.all? { |attr| headers.include? attr } errors.add :file, :headers, required_headers: ATTRIBUTES.join(", ") end diff --git a/app/models/poll.rb b/app/models/poll.rb index bba437132..9f48cc258 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -44,7 +44,7 @@ class Poll < ApplicationRecord scope :expired, -> { where("ends_at < ?", Date.current.beginning_of_day) } scope :recounting, -> { Poll.where(ends_at: (Date.current.beginning_of_day - RECOUNT_DURATION)..Date.current.beginning_of_day) } scope :published, -> { where("published = ?", true) } - scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) } + scope :by_geozone_id, ->(geozone_id) { where(geozones: { id: geozone_id }.joins(:geozones)) } scope :public_for_api, -> { all } scope :not_budget, -> { where(budget_id: nil) } scope :created_by_admin, -> { where(related_type: nil) } diff --git a/app/models/poll/officer.rb b/app/models/poll/officer.rb index 429add05a..c086c5610 100644 --- a/app/models/poll/officer.rb +++ b/app/models/poll/officer.rb @@ -19,14 +19,14 @@ class Poll officer_assignments.voting_days.includes(booth_assignment: :poll). map(&:booth_assignment). map(&:poll).uniq.compact. - sort {|x, y| y.ends_at <=> x.ends_at} + sort { |x, y| y.ends_at <=> x.ends_at } end def final_days_assigned_polls officer_assignments.final.includes(booth_assignment: :poll). map(&:booth_assignment). map(&:poll).uniq.compact. - sort {|x, y| y.ends_at <=> x.ends_at} + sort { |x, y| y.ends_at <=> x.ends_at } end def todays_booths diff --git a/app/models/poll/officer_assignment.rb b/app/models/poll/officer_assignment.rb index 5714d8e74..d619e5406 100644 --- a/app/models/poll/officer_assignment.rb +++ b/app/models/poll/officer_assignment.rb @@ -18,10 +18,10 @@ class Poll scope :by_officer_and_poll, ->(officer_id, poll_id) do where("officer_id = ? AND poll_booth_assignments.poll_id = ?", officer_id, poll_id) end - scope :by_officer, ->(officer){ where(officer_id: officer.id) } - scope :by_poll, ->(poll){ joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) } - scope :by_booth, ->(booth){ joins(:booth_assignment).where("poll_booth_assignments.booth_id" => booth.id) } - scope :by_date, ->(date){ where(date: date) } + scope :by_officer, ->(officer) { where(officer_id: officer.id) } + scope :by_poll, ->(poll) { joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) } + scope :by_booth, ->(booth) { joins(:booth_assignment).where("poll_booth_assignments.booth_id" => booth.id) } + scope :by_date, ->(date) { where(date: date) } before_create :log_user_data diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 41f31c867..0016e0c02 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -33,7 +33,7 @@ class Poll::Question < ApplicationRecord scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } - scope :sort_for_list, -> { order("poll_questions.proposal_id IS NULL", :created_at)} + scope :sort_for_list, -> { order("poll_questions.proposal_id IS NULL", :created_at) } scope :for_render, -> { includes(:author, :proposal) } def self.search(params) diff --git a/app/models/poll/question/answer.rb b/app/models/poll/question/answer.rb index c9856575e..48968e51b 100644 --- a/app/models/poll/question/answer.rb +++ b/app/models/poll/question/answer.rb @@ -76,12 +76,12 @@ class Poll::Question::Answer < ApplicationRecord when "positive_negative_open" answers = question.question_answers.visibles .map { |a| count_positive_negative(a, true) - count_positive_negative(a, false) } - is_most_voted = answers.none? {|a| a > total_votes_positive_negative} + is_most_voted = answers.none? { |a| a > total_votes_positive_negative } update(most_voted: is_most_voted) when "prioritized" answers = question.question_answers.visibles .map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).sum(:value) } - is_most_voted = answers.none? {|a| a > total_votes_prioritized} + is_most_voted = answers.none? { |a| a > total_votes_prioritized } update(most_voted: is_most_voted) else for_only_votes @@ -97,8 +97,8 @@ class Poll::Question::Answer < ApplicationRecord def for_only_votes answers = question.question_answers.visibles - .map {|a| Poll::Answer.where(question_id: a.question, answer: a.title).count} - is_most_voted = answers.none? {|a| a > total_votes} + .map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).count } + is_most_voted = answers.none? { |a| a > total_votes } update(most_voted: is_most_voted) end diff --git a/app/models/poll/recount.rb b/app/models/poll/recount.rb index 56fe36889..6414cbf2a 100644 --- a/app/models/poll/recount.rb +++ b/app/models/poll/recount.rb @@ -7,7 +7,7 @@ class Poll::Recount < ApplicationRecord belongs_to :officer_assignment validates :author, presence: true - validates :origin, inclusion: {in: VALID_ORIGINS} + validates :origin, inclusion: { in: VALID_ORIGINS } scope :web, -> { where(origin: "web") } scope :booth, -> { where(origin: "booth") } diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 79be7eaaa..4ef4b2638 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -78,7 +78,7 @@ class Proposal < ApplicationRecord scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) } scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago) } scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago) } - scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)} + scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) } scope :retired, -> { where.not(retired_at: nil) } scope :not_retired, -> { where(retired_at: nil) } scope :successful, -> { where("cached_votes_up >= ?", Proposal.votes_needed_for_success) } @@ -213,11 +213,11 @@ class Proposal < ApplicationRecord end def after_hide - tags.each{ |t| t.decrement_custom_counter_for("Proposal") } + tags.each { |t| t.decrement_custom_counter_for("Proposal") } end def after_restore - tags.each{ |t| t.increment_custom_counter_for("Proposal") } + tags.each { |t| t.increment_custom_counter_for("Proposal") } end def self.votes_needed_for_success diff --git a/app/models/signature_sheet.rb b/app/models/signature_sheet.rb index beaeb4caa..eb989a9dc 100644 --- a/app/models/signature_sheet.rb +++ b/app/models/signature_sheet.rb @@ -7,7 +7,7 @@ class SignatureSheet < ApplicationRecord has_many :signatures validates :author, presence: true - validates :signable_type, inclusion: {in: VALID_SIGNABLES} + validates :signable_type, inclusion: { in: VALID_SIGNABLES } validates :required_fields_to_verify, presence: true validates :signable, presence: true validate :signable_found @@ -35,7 +35,7 @@ class SignatureSheet < ApplicationRecord end def parsed_required_fields_to_verify_groups - required_fields_to_verify.split(/[;]/).collect {|d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/)} + required_fields_to_verify.split(/[;]/).collect { |d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/) } end def signable_found diff --git a/app/models/tag_cloud.rb b/app/models/tag_cloud.rb index 47b9a94fc..27b6c2d11 100644 --- a/app/models/tag_cloud.rb +++ b/app/models/tag_cloud.rb @@ -20,7 +20,7 @@ class TagCloud end def geozone_names - Geozone.all.map {|geozone| geozone.name.downcase } + Geozone.all.map { |geozone| geozone.name.downcase } end def resource_model_scoped diff --git a/app/models/user.rb b/app/models/user.rb index b5ffacd5f..f15f92ace 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -44,7 +44,7 @@ class User < ApplicationRecord validate :validate_username_length - validates :official_level, inclusion: {in: 0..5} + validates :official_level, inclusion: { in: 0..5 } validates :terms_of_service, acceptance: { allow_nil: false }, on: :create validates_associated :organization, message: false @@ -128,7 +128,7 @@ class User < ApplicationRecord def comment_flags(comments) comment_flags = flags.for_comments(comments) - comment_flags.each_with_object({}){ |f, h| h[f.flaggable_id] = true } + comment_flags.each_with_object({}) { |f, h| h[f.flaggable_id] = true } end def voted_in_group?(group) diff --git a/app/models/votation_type.rb b/app/models/votation_type.rb index 95fd384e2..c518408f7 100644 --- a/app/models/votation_type.rb +++ b/app/models/votation_type.rb @@ -24,12 +24,12 @@ class VotationType < ApplicationRecord variables: [:max_votes, :max_groups_answers] }, }.freeze - enum enum_type: ENUM_TYPES_PROPS.map{ |k,v| [k, v[:enum_type]] }.to_h.freeze + enum enum_type: ENUM_TYPES_PROPS.map { |k, v| [k, v[:enum_type]] }.to_h.freeze - enum prioritization_type: {borda: 1, dowdall: 2}.freeze + enum prioritization_type: { borda: 1, dowdall: 2 }.freeze validates :questionable, presence: true - validates :questionable_type, inclusion: {in: QUESTIONABLE_TYPES} + validates :questionable_type, inclusion: { in: QUESTIONABLE_TYPES } validates_presence_of :max_votes, allow_blank: false, if: :max_votes_required? validates_presence_of :max_groups_answers, allow_blank: false, @@ -49,7 +49,7 @@ class VotationType < ApplicationRecord prioritized end - def answer (user, answer, options = {}) + def answer(user, answer, options = {}) result = nil votes = questionable.answers @@ -130,7 +130,7 @@ class VotationType < ApplicationRecord end def self.build_by_type(questionable, params) - attributes = {questionable: questionable} + attributes = { questionable: questionable } enum_type = self.enum_types.key(params[:enum_type].to_i) enum_type_props = enum_properties(enum_type) attributes.merge!(enum_type_props.except(:variables)) @@ -155,7 +155,7 @@ class VotationType < ApplicationRecord end when "dowdall" questionable.answers.by_author(user).order(:order).each_with_index do |answer, i| - value = 60/(i + 1) + value = 60 / (i + 1) !answer.update(value: value) end end diff --git a/app/views/admin/banners/_form.html.erb b/app/views/admin/banners/_form.html.erb index f6e17cf10..0195d8e52 100644 --- a/app/views/admin/banners/_form.html.erb +++ b/app/views/admin/banners/_form.html.erb @@ -32,14 +32,14 @@
<%= translations_form.text_field :title, placeholder: t("admin.banners.banner.title"), - data: {js_banner_title: "js_banner_title"}, + data: { js_banner_title: "js_banner_title" }, label: t("admin.banners.banner.title") %>
<%= translations_form.text_field :description, placeholder: t("admin.banners.banner.description"), - data: {js_banner_description: "js_banner_description"}, + data: { js_banner_description: "js_banner_description" }, label: t("admin.banners.banner.description") %>
<% end %> diff --git a/app/views/admin/budget_headings/_form.html.erb b/app/views/admin/budget_headings/_form.html.erb index 45f927ed3..fd3c9bc58 100644 --- a/app/views/admin/budget_headings/_form.html.erb +++ b/app/views/admin/budget_headings/_form.html.erb @@ -30,8 +30,8 @@ label: false, maxlength: 8, placeholder: t("admin.budget_headings.form.population"), - data: {toggle_focus: "population-info"}, - aria: {describedby: "budgets-population-help-text"} %> + data: { toggle_focus: "population-info" }, + aria: { describedby: "budgets-population-help-text" } %> <%= f.text_field :latitude, label: t("admin.budget_headings.form.latitude"), diff --git a/app/views/admin/budget_investments/_search_form.html.erb b/app/views/admin/budget_investments/_search_form.html.erb index fb55c384b..80b722bed 100644 --- a/app/views/admin/budget_investments/_search_form.html.erb +++ b/app/views/admin/budget_investments/_search_form.html.erb @@ -2,7 +2,7 @@ <%= form_tag(admin_budget_budget_investments_path(budget: @budget), method: :get, enforce_utf8: false) do %>
<%= link_to "#advanced_filters_content", - data: {toggle: "advanced_filters"}, + data: { toggle: "advanced_filters" }, class: "advanced-filters float-right clear" do %> <%= t("admin.budget_investments.index.advanced_filters") %> <% end %> @@ -36,32 +36,32 @@ <%= select_tag :administrator_id, options_for_select(admin_select_options, params[:administrator_id]), { prompt: t("admin.budget_investments.index.administrator_filter_all"), - label: false} %> + label: false } %>
<%= select_tag :valuator_or_group_id, options_for_select(valuator_or_group_select_options, params[:valuator_or_group_id]), { prompt: t("admin.budget_investments.index.valuator_filter_all"), - label: false} %> + label: false } %>
<%= select_tag :heading_id, options_for_select(budget_heading_select_options(@budget), params[:heading_id]), { prompt: t("admin.budget_investments.index.heading_filter_all"), - label: false} %> + label: false } %>
<%= select_tag :tag_name, options_for_select(investment_tags_select_options(@budget), params[:tag_name]), { prompt: t("admin.budget_investments.index.tags_filter_all"), - label: false} %> + label: false } %>
<%= select_tag :milestone_tag_name, options_for_select(investment_milestone_tags_select_options(@budget), params[:milestone_tag_name]), { prompt: t("admin.budget_investments.index.milestone_tags_filter_all"), - label: false} %> + label: false } %>
diff --git a/app/views/admin/budget_investments/_select_investment.html.erb b/app/views/admin/budget_investments/_select_investment.html.erb index b54efda68..793e05c7c 100644 --- a/app/views/admin/budget_investments/_select_investment.html.erb +++ b/app/views/admin/budget_investments/_select_investment.html.erb @@ -47,7 +47,7 @@ - <%= investment.valuation_finished? ? t("shared.yes"): t("shared.no") %> + <%= investment.valuation_finished? ? t("shared.yes") : t("shared.no") %> @@ -94,6 +94,6 @@ <% if params[:advanced_filters]&.include?("selected") %> - <%= investment.incompatible? ? t("shared.yes"): t("shared.no") %> + <%= investment.incompatible? ? t("shared.yes") : t("shared.no") %> <% end %> diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb index 736a17db4..8051783c7 100644 --- a/app/views/admin/budget_investments/edit.html.erb +++ b/app/views/admin/budget_investments/edit.html.erb @@ -53,7 +53,7 @@
<%= f.select(:administrator_id, - @admins.collect{ |a| [a.description_or_name_and_email, a.id ] }, + @admins.collect { |a| [a.description_or_name_and_email, a.id] }, { include_blank: t("admin.budget_investments.edit.undefined") }) %>
diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb index 6b628f304..f9fa144e9 100644 --- a/app/views/admin/budget_investments/show.html.erb +++ b/app/views/admin/budget_investments/show.html.erb @@ -1,5 +1,5 @@ <%= link_to admin_budget_budget_investments_path(Budget::Investment.filter_params(params).to_h), - class: "back", data: {no_turbolink: true} do %> + class: "back", data: { no_turbolink: true } do %> <%= t("shared.back") %> <% end %> @@ -62,7 +62,7 @@

<%= link_to t("admin.budget_investments.show.edit_classification"), edit_admin_budget_budget_investment_path(@budget, @investment, - {anchor: "classification"}.merge(Budget::Investment.filter_params(params).to_h)) unless @budget.finished? %> + { anchor: "classification" }.merge(Budget::Investment.filter_params(params).to_h)) unless @budget.finished? %>


diff --git a/app/views/admin/dashboard/actions/_form.html.erb b/app/views/admin/dashboard/actions/_form.html.erb index 8a8588d77..59e74690a 100644 --- a/app/views/admin/dashboard/actions/_form.html.erb +++ b/app/views/admin/dashboard/actions/_form.html.erb @@ -6,7 +6,7 @@ <% ::Dashboard::Action.action_types.keys.each do |action_type_value| %> <%= f.radio_button :action_type, action_type_value, label: false, - data: {toggle: "request_to_administrators short_description"} %> + data: { toggle: "request_to_administrators short_description" } %> <%= f.label "action_type_#{action_type_value}", t("admin.dashboard.actions.action_type.#{action_type_value}") %> <% end %> diff --git a/app/views/admin/hidden_users/show.html.erb b/app/views/admin/hidden_users/show.html.erb index 9eae29589..0a95eab12 100644 --- a/app/views/admin/hidden_users/show.html.erb +++ b/app/views/admin/hidden_users/show.html.erb @@ -36,4 +36,4 @@ <% end %> -<%= paginate [@debates, @comments].sort_by {|x| x.size}.last %> +<%= paginate [@debates, @comments].sort_by { |x| x.size }.last %> diff --git a/app/views/admin/homepage/_setting.html.erb b/app/views/admin/homepage/_setting.html.erb index dc95a5f9c..15040f685 100644 --- a/app/views/admin/homepage/_setting.html.erb +++ b/app/views/admin/homepage/_setting.html.erb @@ -6,6 +6,6 @@ <%= f.submit(t("admin.settings.index.features.#{setting.enabled? ? "disable" : "enable"}"), class: "button #{setting.enabled? ? "hollow alert" : "success"}", - data: {confirm: t("admin.actions.confirm")}) %> + data: { confirm: t("admin.actions.confirm") }) %> <% end %> diff --git a/app/views/admin/legislation/draft_versions/_form.html.erb b/app/views/admin/legislation/draft_versions/_form.html.erb index 3ef7247b4..d0cf4f317 100644 --- a/app/views/admin/legislation/draft_versions/_form.html.erb +++ b/app/views/admin/legislation/draft_versions/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: @draft_version %> -<%= translatable_form_for [:admin, @process, @draft_version], url: url, html: {data: {watch_changes: true}} do |f| %> +<%= translatable_form_for [:admin, @process, @draft_version], url: url, html: { data: { watch_changes: true }} do |f| %> <% if @draft_version.errors.any? %>
@@ -38,7 +38,7 @@
<%= t("admin.legislation.draft_versions.form.title_html", draft_version_title: @draft_version.title, - process_title: @process.title ) %> + process_title: @process.title) %>
diff --git a/app/views/admin/legislation/homepages/_form.html.erb b/app/views/admin/legislation/homepages/_form.html.erb index 4ce79ab30..4169f0127 100644 --- a/app/views/admin/legislation/homepages/_form.html.erb +++ b/app/views/admin/legislation/homepages/_form.html.erb @@ -3,7 +3,7 @@ display_style: lambda { |locale| enable_translation_style(@process, locale) }, manage_languages: false %> -<%= translatable_form_for [:admin, @process], url: url, html: {data: {watch_changes: true}} do |f| %> +<%= translatable_form_for [:admin, @process], url: url, html: { data: { watch_changes: true } } do |f| %> <%= render "shared/errors", resource: @process %>
diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index d95f65598..a100c2dc9 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: @process %> -<%= translatable_form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %> +<%= translatable_form_for [:admin, @process], html: { data: { watch_changes: true } } do |f| %> <% if @process.errors.any? %> diff --git a/app/views/admin/legislation/proposals/_form.html.erb b/app/views/admin/legislation/proposals/_form.html.erb index 63617c57d..19e0afe3a 100644 --- a/app/views/admin/legislation/proposals/_form.html.erb +++ b/app/views/admin/legislation/proposals/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_for [:admin, @process], html: {data: {watch_changes: true}} do |f| %> +<%= form_for [:admin, @process], html: { data: { watch_changes: true } } do |f| %> <% if @process.errors.any? %> @@ -22,7 +22,7 @@ label: false, placeholder: t("admin.legislation.proposals.form.custom_categories_placeholder"), class: "js-tag-list", - aria: {describedby: "tag-list-help-text"} %> + aria: { describedby: "tag-list-help-text" } %>
diff --git a/app/views/admin/legislation/questions/_form.html.erb b/app/views/admin/legislation/questions/_form.html.erb index 22964c95a..beefabeb9 100644 --- a/app/views/admin/legislation/questions/_form.html.erb +++ b/app/views/admin/legislation/questions/_form.html.erb @@ -1,6 +1,6 @@ <%= render "shared/globalize_locales", resource: @question %> -<%= translatable_form_for [:admin, @process, @question], url: url, html: {data: {watch_changes: true}} do |f| %> +<%= translatable_form_for [:admin, @process, @question], url: url, html: { data: { watch_changes: true } } do |f| %> <% if @question.errors.any? %>
diff --git a/app/views/admin/poll/booth_assignments/_booth_assignment.html.erb b/app/views/admin/poll/booth_assignments/_booth_assignment.html.erb index 57cc8eaf0..13857144a 100644 --- a/app/views/admin/poll/booth_assignments/_booth_assignment.html.erb +++ b/app/views/admin/poll/booth_assignments/_booth_assignment.html.erb @@ -17,7 +17,7 @@ remote: true, title: t("admin.booth_assignments.manage.actions.unassign"), class: "button hollow alert expanded", - data: (booth_assignment.shifts? ? {confirm: "#{t("admin.poll_booth_assignments.alert.shifts")}"} : nil) if !@poll.expired? %> + data: (booth_assignment.shifts? ? { confirm: "#{t("admin.poll_booth_assignments.alert.shifts")}" } : nil) if !@poll.expired? %> <% else %> diff --git a/app/views/admin/poll/officers/_officer.html.erb b/app/views/admin/poll/officers/_officer.html.erb index 21a5bbdbc..70fc18ec1 100644 --- a/app/views/admin/poll/officers/_officer.html.erb +++ b/app/views/admin/poll/officers/_officer.html.erb @@ -21,7 +21,7 @@ method: :delete, class: "button hollow alert expanded" %> <% else %> - <%= link_to t("admin.poll_officers.officer.add"),{ controller: "admin/poll/officers", action: :create, user_id: officer.user_id }, + <%= link_to t("admin.poll_officers.officer.add"), { controller: "admin/poll/officers", action: :create, user_id: officer.user_id }, method: :post, class: "button success expanded" %> <% end %> diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 350f25d75..67b3941c9 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -37,7 +37,7 @@ <%= fields_for :votation_type do |votation_f| %>
<%= votation_f.select :enum_type, - options_for_select(VotationType.enum_types.map {|k, v| [t(k, scope: :enum_type), v]}, + options_for_select(VotationType.enum_types.map { |k, v| [t(k, scope: :enum_type), v] }, params.dig(:votation_type, :enum_type)), default: 0, disabled: @question.persisted?, label: t("enum_type.title") %>
@@ -53,8 +53,8 @@