Class: Fastui::MOrgsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#createObject



31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/fastui/m_orgs_controller.rb', line 31

def create
  @m_org = MOrg.new(params[:m_org])
  respond_with(@m_org) do |format|
    if @m_org.save
      format.json { render :json => {:success => true, :msg => 'ok'} }
    else
      format.json { render :json => {:success => false, :msg => 'failure'} }
    end
  end

end

#destroyObject



55
56
57
58
59
# File 'app/controllers/fastui/m_orgs_controller.rb', line 55

def destroy
  @m_org = MOrg.find(params[:id])
  @m_org.destroy
  respond_with(@m_org)
end

#editObject



21
22
23
24
# File 'app/controllers/fastui/m_orgs_controller.rb', line 21

def edit
  @m_org = MOrg.find(params[:id])
  respond_with(@m_org.to_json(:include => [:parent]))
end

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/fastui/m_orgs_controller.rb', line 7

def index
  #@m_orgs = MOrg.scoped
  @m_orgs = params[:node] == '' ? MOrg.roots : MOrg.where({
                                                                :parent_id => params[:node]
                                                            }.delete_if { |k, v| v.blank? })

  respond_with(@m_orgs.to_json(:include => [:parent], :methods => [:leaf, :expanded]))
end

#newObject



26
27
28
29
# File 'app/controllers/fastui/m_orgs_controller.rb', line 26

def new
  @m_org = MOrg.new
  respond_with(@m_org)
end

#showObject



16
17
18
19
# File 'app/controllers/fastui/m_orgs_controller.rb', line 16

def show
  @m_org = MOrg.find(params[:id])
  respond_with(@m_org)
end

#updateObject



43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/fastui/m_orgs_controller.rb', line 43

def update
  @m_org = MOrg.find(params[:id])

  respond_with(@m_org) do |format|
    if @m_org.update_attributes(params[:m_org])
      format.json { render :json => {:success => true, :msg => 'ok'} }
    else
      format.json { render :json => {:success => false, :msg => 'false'} }
    end
  end
end