Class: DomainsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/domains_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

JSON only



21
22
23
24
25
26
27
28
# File 'app/controllers/domains_controller.rb', line 21

def create # JSON only
  @domain = current_admin_user.build_domain(params[:virtual_domain])
  if @domain.save
    render :json => {:domain => @domain}
  else
    render :json => {:errors => @domain.errors}
  end
end

#destroyObject

JSON only



41
42
43
44
45
46
# File 'app/controllers/domains_controller.rb', line 41

def destroy # JSON only
  current_admin_user.domain(params[:id]).destroy
  render :json => {:id => nil}
rescue
  render :status => 405
end

#indexObject



3
4
5
6
7
8
9
# File 'app/controllers/domains_controller.rb', line 3

def index
  @domains = current_admin_user.domains
  respond_to do |format|
    format.html # index.html.haml
    format.json { render :json => @domains }
  end
end

#showObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/domains_controller.rb', line 11

def show
  @domain = current_admin_user.domain(params[:id])
  respond_to do |format|
    format.html # show.html.haml
    format.json { render :json => @domain }
  end
rescue
  render :status => 404
end

#updateObject

JSON only



30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/domains_controller.rb', line 30

def update # JSON only
  @domain = current_admin_user.domain(params[:id])
  if @domain.update_attributes params[:virtual_domain]
    render :json => {:id => @domain.id}
  else
    render :json => {:errors => @domain.errors}
  end
rescue
  render :status => 405
end