Class: BadgesEngine::BadgesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/badges_engine/badges_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /badges POST /badges.json



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/badges_engine/badges_controller.rb', line 43

def create
  @badge = Badge.new(params[:badge])
  
  respond_to do |format|
    if @badge.save
      format.html { redirect_to @badge, notice: 'Badge was successfully created.' }
      format.json { render json: @badge, status: :created, location: @badge }
    else
      format.html { render action: "new" }
      format.json { render json: @badge.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /badges/1 DELETE /badges/1.json



75
76
77
78
79
80
81
82
83
# File 'app/controllers/badges_engine/badges_controller.rb', line 75

def destroy
  @badge = Badge.find(params[:id])
  @badge.destroy
  
  respond_to do |format|
    format.html { redirect_to badges_url }
    format.json { head :ok }
  end
end

#editObject

GET /badges/1/edit



37
38
39
# File 'app/controllers/badges_engine/badges_controller.rb', line 37

def edit
  @badge = Badge.find(params[:id])
end

#indexObject

GET /badges GET /badges.json



5
6
7
8
9
10
11
12
# File 'app/controllers/badges_engine/badges_controller.rb', line 5

def index
  @badges = Badge.all
  
  respond_to do |format|
    format.html # index.html.haml
    format.json { render json: @badges }
  end
end

#newObject

GET /badges/new GET /badges/new.json



27
28
29
30
31
32
33
34
# File 'app/controllers/badges_engine/badges_controller.rb', line 27

def new
  @badge = Badge.new
  
  respond_to do |format|
    format.html # new.html.haml
    format.json { render json: @badge }
  end
end

#showObject

GET /badges/1 GET /badges/1.json



16
17
18
19
20
21
22
23
# File 'app/controllers/badges_engine/badges_controller.rb', line 16

def show
  @badge = Badge.find(params[:id])
  
  respond_to do |format|
    format.html # show.html.haml
    format.json { render json: @badge }
  end
end

#updateObject

PUT /badges/1 PUT /badges/1.json



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/badges_engine/badges_controller.rb', line 59

def update
  @badge = Badge.find(params[:id])
  
  respond_to do |format|
    if @badge.update_attributes(params[:badge])
      format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render action: "edit" }
      format.json { render json: @badge.errors, status: :unprocessable_entity }
    end
  end
end