Class: Fastui::MMenuItemsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#createObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 37

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

end

#destroyObject



61
62
63
64
65
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 61

def destroy
  @m_menu_item = MMenuItem.find(params[:id])
  @m_menu_item.destroy
  respond_with(@m_menu_item)
end

#editObject



27
28
29
30
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 27

def edit
  @m_menu_item = MMenuItem.find(params[:id])
  respond_with(@m_menu_item.to_json(:include => [:m_menu, :createdbyorg, :createdby, :updatedby]))
end

#indexObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 8

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

  #if params[:id] == 'root'
  #  @m_menu_items = MMenuItem.roots
  #else
  #  @m_menu_items = MMenuItem.where({:parent_id => params[:id]}.delete_if { |k, v| v.blank?})
    #@m_menu_items = paginate(@items)
  #end
  respond_with(@m_menu_items.to_json(:include => [:m_menu, :createdbyorg, :createdby, :updatedby], :methods => [:leaf, :expanded]))
end

#newObject



32
33
34
35
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 32

def new
  @m_menu_item = MMenuItem.new
  respond_with(@m_menu_item)
end

#showObject



22
23
24
25
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 22

def show
  @m_menu_item = MMenuItem.find(params[:id])
  respond_with(@m_menu_item)
end

#updateObject



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/fastui/m_menu_items_controller.rb', line 49

def update
  @m_menu_item = MMenuItem.find(params[:id])

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