0

Here I am getting values from my model and I am putting it as an instance variable in my controller:

@users = User.where(:approved => true, :enabled => true)

now I want @users to behave as an array so that I can perform the following operation:

@users = @users | current_user 

i.e an array union. any pointers ?

2 Answers 2

1
@users = User.where(:approved => true, :enabled => true).to_a
Sign up to request clarification or add additional context in comments.

Comments

0

this would initialize the @current_user array:

@current_user = [current_user]

then I did

@users = @current_user | @users

and it worked!

Please suggest if you have a better solution.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.