Avoid instance variable in view helpers

rubocop rule Rails/HelperInstanceVariable
pull/10063/head
Christophe Bliard 3 years ago
parent 2fec9a8795
commit ff4367b084
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 2
      app/controllers/groups_controller.rb
  2. 9
      app/helpers/groups_helper.rb
  3. 2
      app/views/groups/_users.html.erb

@ -75,8 +75,6 @@ class GroupsController < ApplicationController
# GET /groups/1/edit
def edit
@group = Group.includes(:members, :users).find(params[:id])
set_filters_for_user_autocompleter
end
# POST /groups

@ -58,9 +58,10 @@ module GroupsHelper
]
end
def set_filters_for_user_autocompleter
@autocompleter_filters = []
@autocompleter_filters.push({ selector: 'status', operator: '=', values: ['active', 'invited'] })
@autocompleter_filters.push({ selector: 'group', operator: '!', values: [@group.id] })
def autocompleter_filters(group)
[
{ selector: 'status', operator: '=', values: ['active', 'invited'] },
{ selector: 'group', operator: '!', values: [group.id] }
]
end
end

@ -55,7 +55,7 @@ See COPYRIGHT and LICENSE files for more details.
<div class="form--field -vertical">
<%= hidden_field_tag :user_ids, nil %>
<user-autocompleter data-update-input="user_ids"
data-additional-filter="<%= @autocompleter_filters&.to_json %>"
data-additional-filter="<%= autocompleter_filters(@group).to_json %>"
class="new-group-members--autocomplete">
</user-autocompleter>
</div>

Loading…
Cancel
Save