Class: Fastui::MListItemsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/fastui/m_list_items_controller.rb', line 33

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

end

#destroyObject



57
58
59
60
61
# File 'app/controllers/fastui/m_list_items_controller.rb', line 57

def destroy
  @m_list_item = MListItem.find(params[:id])
  @m_list_item.destroy
  respond_with(@m_list_item)
end

#editObject



23
24
25
26
# File 'app/controllers/fastui/m_list_items_controller.rb', line 23

def edit
  @m_list_item = MListItem.find(params[:id])
  respond_with(@m_list_item.to_json(:include => [:m_list]))
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/fastui/m_list_items_controller.rb', line 6

def index
  list = MList.where({
                              :name => params[:list_name]
                          }.delete_if {|k, v| v.blank? })

  @m_list_items = MListItem.where({
                                      :m_list_id => params[:m_list_id] || list
                                  }.delete_if {|k, v| v.blank? })
  #data = paginate(@m_list_items)
  respond_with(@m_list_items.to_json(:include =>[:m_list,:createdbyorg,:createdby,:updatedby]))
end

#newObject



28
29
30
31
# File 'app/controllers/fastui/m_list_items_controller.rb', line 28

def new
  @m_list_item = MListItem.new
  respond_with(@m_list_item)
end

#showObject



18
19
20
21
# File 'app/controllers/fastui/m_list_items_controller.rb', line 18

def show
  @m_list_item = MListItem.find(params[:id])
  respond_with(@m_list_item)
end

#updateObject



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/fastui/m_list_items_controller.rb', line 45

def update
  @m_list_item = MListItem.find(params[:id])

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