Class: UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_in_path_for, #any_admin_user_exists?, #first_admin_user_action?

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/users_controller.rb', line 15

def create
  @domain = current_admin_user.domain(params[:domain_id])
  @user = @domain.virtual_users.build(params[:virtual_user])
  if @user.save
    render :json => {:id => @user.id}
  else
    render :json => {:errors => @user.errors}
  end
rescue
  render :json => {:errors => t('unknown_error')}
end

#destroyObject



27
28
29
30
31
32
# File 'app/controllers/users_controller.rb', line 27

def destroy
  @user.destroy
  render :json => {:id => nil}
rescue
  render :json => {:errors => t('unknown_error')}
end

#updateObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/users_controller.rb', line 5

def update
  if @user.change_data params[:virtual_user]
    render :json => {:id => @user.id}
  else
    render :json => {:errors => @user.errors}
  end
rescue
  render :json => {:errors => t('unknown_error')}
end