Class: Fastui::MPeopleController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#createObject



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/fastui/m_people_controller.rb', line 42

def create
  @m_person = MPerson.new(params[:m_person])
  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



66
67
68
69
70
# File 'app/controllers/fastui/m_people_controller.rb', line 66

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

#editObject



32
33
34
35
# File 'app/controllers/fastui/m_people_controller.rb', line 32

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

#indexObject



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

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.scoped
  data = paginate(@m_people)
  respond_with(data.to_json)
end

#loginObject



72
73
74
75
76
77
78
79
80
81
82
# File 'app/controllers/fastui/m_people_controller.rb', line 72

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



84
85
86
# File 'app/controllers/fastui/m_people_controller.rb', line 84

def logout

end

#newObject



37
38
39
40
# File 'app/controllers/fastui/m_people_controller.rb', line 37

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

#showObject



27
28
29
30
# File 'app/controllers/fastui/m_people_controller.rb', line 27

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

#updateObject



54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/fastui/m_people_controller.rb', line 54

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

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