Class: Bolt::GroupsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bolt/groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /bolt/groups POST /bolt/groups.json



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/bolt/groups_controller.rb', line 44

def create
  @group = Group.new(params[:group])

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

#destroyObject

DELETE /bolt/groups/1 DELETE /bolt/groups/1.json



76
77
78
79
80
81
82
83
84
# File 'app/controllers/bolt/groups_controller.rb', line 76

def destroy
  @group = Group.find(params[:id])
  @group.destroy

  respond_to do |format|
    format.html { redirect_to groups_url }
    format.json { head :ok }
  end
end

#destroy_multipleObject



86
87
88
89
90
91
92
93
94
95
96
97
# File 'app/controllers/bolt/groups_controller.rb', line 86

def destroy_multiple
  ids= params[:id]
  idarr=ids.split(',')
  idarr.each do |del|
   @group = Group.find(del)
   @group.destroy
 end
 respond_to do |format|
   format.html { redirect_to :back  }
   # format.json { head :ok }
 end
end

#editObject

GET /bolt/groups/1/edit



38
39
40
# File 'app/controllers/bolt/groups_controller.rb', line 38

def edit
  @group = Group.find(params[:id])
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/bolt/groups_controller.rb', line 6

def index
 sortcolumn=(params[:sort]==nil)? 'name' : params[:sort]  
 @groups = Group.find(:all, :order => sortcolumn)
  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @groups }
  end
end

#newObject

GET /bolt/groups/new GET /bolt/groups/new.json



28
29
30
31
32
33
34
35
# File 'app/controllers/bolt/groups_controller.rb', line 28

def new
  @group = Group.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @group }
  end
end

#showObject

GET /bolt/groups/1 GET /bolt/groups/1.json



17
18
19
20
21
22
23
24
# File 'app/controllers/bolt/groups_controller.rb', line 17

def show
  @group = Group.find(params[:id])

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

#updateObject

PUT /bolt/groups/1 PUT /bolt/groups/1.json



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/bolt/groups_controller.rb', line 60

def update
  @group = Group.find(params[:id])

  respond_to do |format|
    if @group.update_attributes(params[:group])
      format.html { redirect_to :action=>"index", :notice => 'Group was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @group.errors, :status => :unprocessable_entity }
    end
  end
end