[Solved] Add user without signup form in rails


At first, you need to create a migration and add a new column to the users table. I think it is better to keep info about admin creating in the db (if you don’t want to store it, just add :created_by_admin to attr_accessor list instead of this step).

add_column :users, :created_by_admin, :boolean, default: false, null: false

Add this new field to the form (‘added by admin’):

<%= f.hidden_field :created_by_admin, value: true %>

Add condition to email validation:

validates :email, presence: true, uniqueness: { case_sensitive: false },
  format: { with: VALID_EMAIL_REGEX }, unless: :created_by_admin?

5

solved Add user without signup form in rails