user.rb
class User < ActiveRecord::Base
has_and_belongs_to_many :user_groups
end
Similarly, user_group.rb
class UserGroup < ActiveRecord::Base
has_and_belongs_to_many :users
end
Now the active admin page for user groups is as shown below:
ActiveAdmin.register UserGroup, as: 'UserGroup' do
form do |f|
f.inputs do
f.has_many :usergroup_users, as: 'member user' do |user|
user.input :user_id
end
end
end
end
Now this will create the user group form with fields for adding users to the new group. The button for adding new user to the group will be Add new User Group User
. I want to modify this button label to something else. How can it be implemented?
Part of my problem is solved when using:
f.has_many :usergroup_users, heading: 'Add User to Group', as: 'member user' do |user|
...
end
This will change the header part to the required text. But the button label is still be a problem.
f.has_many :usergroup_users, new_record: 'Add member user' do |user|
...
end
The new_record
attribute can be used to customize the button label.