Class: FastExt::MPeopleController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #paginate

Instance Method Details

#createObject



44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/fast_ext/m_people_controller.rb', line 44

def create
  @m_person = MPerson.new(m_person_params)
  respond_with(@m_person) do |format|
    if @m_person.save
      format.json { render :json => {:success => true, :msg => 'ok'} }
    else
      format.json { render :json => {:success => false, :msg => 'failure'} }
    end
  end

end

#destroyObject



68
69
70
71
72
# File 'app/controllers/fast_ext/m_people_controller.rb', line 68

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

#editObject



34
35
36
37
# File 'app/controllers/fast_ext/m_people_controller.rb', line 34

def edit
  #@m_person = MPerson.find(params[:id])
  respond_with(@m_person)
end

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/fast_ext/m_people_controller.rb', line 9

def index
  #limit = params[:limit].to_i
  #start = params[:start].to_i
  #search = params[:search]
  #if search.blank?
  #  @m_people = MPerson.all
  #  @records = MPerson.limit(limit).offset(start)
  #else
  #  @m_people = MPerson.where("title LIKE :input", {:input => "%#{search}%"})
  #  @records = @m_people.limit(limit).offset(start)
  #end
  #data ={
  #    :totalCount => @m_people.length,
  #    :rows => @records
  #}
  @m_people = MPerson.all
  data = paginate(@m_people)
  respond_with(data.to_json)
end

#loginObject



74
75
76
77
78
79
80
81
82
83
84
# File 'app/controllers/fast_ext/m_people_controller.rb', line 74

def 
  @m_person = MPerson.where(:name => params[:UserName]).first_or_initialize
  respond_with(@m_person) do |format|
    if @m_person
      format.json { render :json => {:success => true, :msg => 'ok'} }
    else
      format.json { render :json => {:success => false, :msg => 'false'} }
    end
  end

end

#logoutObject



86
87
88
# File 'app/controllers/fast_ext/m_people_controller.rb', line 86

def logout

end

#newObject



39
40
41
42
# File 'app/controllers/fast_ext/m_people_controller.rb', line 39

def new
  @m_person = MPerson.new
  respond_with(@m_person)
end

#showObject



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

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

#updateObject



56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/fast_ext/m_people_controller.rb', line 56

def update
  #@m_person = MPerson.find(params[:id])

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