0

In my active admin form I'm retrieving multiple users with email, name, mobile attribute. I want to display this in table format like email, name, mobile as indexes.

     f.input :user_ids, :label => "Users", 
  :multiple => true,  collection: @user.collect{|u| [[u.email, u.name, u.mobile].to_s.gsub('"',""), u.id]}, 
  :required => true, :input_html => { :class => "users_checkboxes", :size => 20 

Ex: Above code display the following:

[[email protected],Robert,78789799]

[[email protected],Kamal,99098889]

I want to display in proper order like space between email, name and mobile, so that make appearance better.

0

1 Answer 1

1

You can use join to display the user information in a better way, for example:

:multiple => true,  collection: @user.collect{|u| [[u.email, u.name, u.mobile].join(" - "), u.id]}

Then the result will be displayed like this:

[email protected] - Robert - 78789799

Just substitute the dash with anything you prefer.

Sign up to request clarification or add additional context in comments.

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.