Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ def update
private

def search_params
{s: 'member_uid asc'}.merge(params.fetch(:q, {}))
q = params.fetch(:q, {})

if params[:q].present?
q[:member_uid_eq] = q[:user_username_or_user_email_contains]
q[:m] = 'or'
end

{ s: 'member_uid asc' }.merge(q)
end

def scoped_users
Expand Down
5 changes: 0 additions & 5 deletions app/models/member.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
class Member < ActiveRecord::Base
# Cast the member_uid integer to a string to allow pg ILIKE search (from Ransack *_contains)
ransacker :member_uid do
Arel.sql("to_char(member_uid, '9999999')")
end

belongs_to :user
belongs_to :organization
has_one :account, as: :accountable
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="col-md-12">
<%= search_form_for(@search, class: "navbar-form navbar-left", url: users_path) do |f| %>
<div class="form-group">
<%= f.search_field :user_username_or_user_email_or_member_uid_contains, class: "form-control" %>
<%= f.search_field :user_username_or_user_email_contains, class: "form-control" %>
</div>
<button class="btn btn-default" type="submit">
<%= t 'global.search' %>
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
user = Fabricate(:user, username: 'foo', email: 'foo@email.com')
member = Fabricate(:member, user: user, organization: test_organization, member_uid: 1000)

get :index, q: { user_username_or_user_email_or_member_uid_contains: 1000 }
get :index, q: { user_username_or_user_email_contains: 1000 }

expect(assigns(:members)).to include(member)
end
Expand Down