Class: ForemanUsers::SyusersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_users/syusers_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /syusers POST /syusers.json



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/foreman_users/syusers_controller.rb', line 49

def create
  @syuser = ForemanUsers::Syuser.new(params[:foreman_users_syuser])

  respond_to do |format|
    if @syuser.save
      format.html { redirect_to @syuser, notice: 'Syuser was successfully created.' }
      format.json { render json: @syuser, status: :created, location: @syuser }
    else
      format.html { render action: "new" }
      format.json { render json: @syuser.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /syusers/1 DELETE /syusers/1.json



81
82
83
84
85
86
87
88
89
90
91
# File 'app/controllers/foreman_users/syusers_controller.rb', line 81

def destroy
  @syuser = ForemanUsers::Syuser.find(params[:id])
  @syuser.destroy
  @syuser.destory_dir
  respond_to do |format|
    format.html { redirect_to foreman_users_syusers_url }
    format.json { head :no_content }
  end


end

#editObject

GET /syusers/1/edit



37
38
39
40
41
42
43
44
45
# File 'app/controllers/foreman_users/syusers_controller.rb', line 37

def edit
  @syuser = ForemanUsers::Syuser.find(params[:id])
  sygroup_time = @syuser.sygroups.size
  if  sygroup_time == 0 
    5.times { @syuser.sygroups.build}
  else
    5.times { @syuser.sygroups.build}
  end
end

#indexObject

GET /syusers GET /syusers.json



4
5
6
7
8
9
10
11
# File 'app/controllers/foreman_users/syusers_controller.rb', line 4

def index
  @syusers = ForemanUsers::Syuser.all.paginate(:page => params[:page])

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @syusers }
  end
end

#newObject

GET /syusers/new GET /syusers/new.json



26
27
28
29
30
31
32
33
34
# File 'app/controllers/foreman_users/syusers_controller.rb', line 26

def new
  @syuser = ForemanUsers::Syuser.new
  5.times { @syuser.sygroups.build}
  #sygroups = @syuser.sygroups.new
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @syuser }
  end
end

#showObject

GET /syusers/1 GET /syusers/1.json



15
16
17
18
19
20
21
22
# File 'app/controllers/foreman_users/syusers_controller.rb', line 15

def show
  @syuser = ForemanUsers::Syuser.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @syuser }
  end
end

#updateObject

PUT /syusers/1 PUT /syusers/1.json



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/foreman_users/syusers_controller.rb', line 65

def update
  @syuser = ForemanUsers::Syuser.find(params[:id])

  respond_to do |format|
    if @syuser.update_attributes(params[:foreman_users_syuser])
      format.html { redirect_to @syuser, notice: 'Syuser was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @syuser.errors, status: :unprocessable_entity }
    end
  end
end