Class: Fastui::MMenuItemsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Fastui::MMenuItemsController
- Defined in:
- app/controllers/fastui/m_menu_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
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 |
#index ⇒ Object
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 |
#new ⇒ Object
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 |
#show ⇒ Object
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 |
#update ⇒ Object
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 |