Class: FastExt::MListItemsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #paginate

Instance Method Details

#createObject



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

def create
  @m_list_item = MListItem.new(m_list_item_params)
  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



59
60
61
62
63
# File 'app/controllers/fast_ext/m_list_items_controller.rb', line 59

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

#editObject



25
26
27
28
# File 'app/controllers/fast_ext/m_list_items_controller.rb', line 25

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

#indexObject



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

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



30
31
32
33
# File 'app/controllers/fast_ext/m_list_items_controller.rb', line 30

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

#showObject



20
21
22
23
# File 'app/controllers/fast_ext/m_list_items_controller.rb', line 20

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

#updateObject



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

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

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