Class: Fastui::MRolesController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#createObject



28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/fastui/m_roles_controller.rb', line 28

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

end

#destroyObject



52
53
54
55
56
# File 'app/controllers/fastui/m_roles_controller.rb', line 52

def destroy
  @m_role = MRole.find(params[:id])
  @m_role.destroy
  respond_with(@m_role)
end

#editObject



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

def edit
  @m_role = MRole.find(params[:id])
  respond_with(@m_role.to_json({:include => :m_people,:methods => :m_person_ids}))
end

#indexObject



7
8
9
10
11
# File 'app/controllers/fastui/m_roles_controller.rb', line 7

def index        
  @m_roles = MRole.scoped
  data = paginate(@m_roles)
  respond_with(data.to_json({:include => :m_people,:methods => :m_person_ids}))
end

#newObject



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

def new
  @m_role = MRole.new
  respond_with(@m_role)
end

#showObject



13
14
15
16
# File 'app/controllers/fastui/m_roles_controller.rb', line 13

def show
  @m_role = MRole.find(params[:id])
  respond_with(@m_role)
end

#updateObject



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/fastui/m_roles_controller.rb', line 40

def update
  @m_role = MRole.find(params[:id])

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