Class: FastExt::MMenuItemsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #paginate

Instance Method Details

#createObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 34

def create
  @m_menu_item = MMenuItem.new(m_menu_item_params)
  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



58
59
60
61
62
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 58

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

#editObject



24
25
26
27
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 24

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

#indexObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 9

def index
  if params[:node] == 'root'
    @m_menu_items = MMenuItem.roots.where({:m_menu_id => params[:m_menu_id]}.delete_if { |k, v| v.blank? })
  else
    @m_menu_items = MMenuItem.where({:parent_id => params[:node]}.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



29
30
31
32
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 29

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

#showObject



19
20
21
22
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 19

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

#updateObject



46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/fast_ext/m_menu_items_controller.rb', line 46

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

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