我在应用程序中有一个字段,当前允许组管理员邀请其他用户(加入组)。它适用于单个值,但我想知道如何调整它,以便它允许管理员在字段中输入多个用逗号分隔的用户。
# form in view
<%= form_tag({:controller => "group_members", :action => "invite_user"}, :method => "post") do %>
<%= hidden_field_tag 'group_id', @group.id%>
<%= text_field_tag :user_name %>
<%= submit_tag "Invite" %>
<% end %>
# group_members_controller
def invite_user
@user = User.find_by_user_name(params[:user_name])
@group_member = GroupMember.create!(:status=>"invited", :user_id=>@user.id, :group_id => params[:group_id], :token => SecureRandom.urlsafe_base64)
redirect_to :back, notice: "#{@user.user_name} has been invited to your group"
end