Class: BadgesEngine::AssertionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- BadgesEngine::AssertionsController
- Defined in:
- app/controllers/badges_engine/assertions_controller.rb
Instance Method Summary collapse
- #bake_callback ⇒ Object
-
#create ⇒ Object
POST /assertions POST /assertions.json.
-
#destroy ⇒ Object
DELETE /assertions/1 DELETE /assertions/1.json.
-
#edit ⇒ Object
GET /assertions/1/edit.
-
#index ⇒ Object
GET /assertions GET /assertions.json.
-
#new ⇒ Object
GET /assertions/new GET /assertions/new.json.
-
#show ⇒ Object
GET /assertions/1 GET /assertions/1.json.
-
#update ⇒ Object
PUT /assertions/1 PUT /assertions/1.json.
Instance Method Details
#bake_callback ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 4 def bake_callback @assertion = Assertion.find(params[:id]) respond_to do |format| if @assertion && @assertion.token == params[:token] format.html { render action: 'show' } format.json { render json: @assertion.open_badges_as_json } else format.html {render text: 'Cannot access badge assertion.', status: :unauthorized} format.json { error = {status: 'failure', error: 'unauthorized', reason: 'Cannot access badge assertion.'} render json: error, status: :unauthorized } end end end |
#create ⇒ Object
POST /assertions POST /assertions.json
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 60 def create @assertion = Assertion.new(params[:assertion]) respond_to do |format| if @assertion.save format.html { redirect_to @assertion, notice: 'Assertion was successfully created.' } format.json { render json: @assertion, status: :created, location: @assertion } else format.html { render action: "new" } format.json { render json: @assertion.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /assertions/1 DELETE /assertions/1.json
92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 92 def destroy @assertion = Assertion.find(params[:id]) @assertion.destroy respond_to do |format| format.html { redirect_to assertions_url } format.json { head :ok } end end |
#edit ⇒ Object
GET /assertions/1/edit
54 55 56 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 54 def edit @assertion = Assertion.find(params[:id]) end |
#index ⇒ Object
GET /assertions GET /assertions.json
22 23 24 25 26 27 28 29 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 22 def index @assertions = Assertion.all respond_to do |format| format.html # index.html.haml format.json { render json: @assertions } end end |
#new ⇒ Object
GET /assertions/new GET /assertions/new.json
44 45 46 47 48 49 50 51 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 44 def new @assertion = Assertion.new respond_to do |format| format.html # new.html.haml format.json { render json: @assertion } end end |
#show ⇒ Object
GET /assertions/1 GET /assertions/1.json
33 34 35 36 37 38 39 40 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 33 def show @assertion = Assertion.find(params[:id]) respond_to do |format| format.html # show.html.haml format.json { render json: @assertion } end end |
#update ⇒ Object
PUT /assertions/1 PUT /assertions/1.json
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/badges_engine/assertions_controller.rb', line 76 def update @assertion = Assertion.find(params[:id]) respond_to do |format| if @assertion.update_attributes(params[:assertion]) format.html { redirect_to @assertion, notice: 'Assertion was successfully updated.' } format.json { head :ok } else format.html { render action: "edit" } format.json { render json: @assertion.errors, status: :unprocessable_entity } end end end |