Class: RatingsController

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

Overview

Restful controller for Ratings

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_for_mobile, #mobile_device?

Instance Method Details

#createObject

POST /ratings POST /ratings.json


30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/ratings_controller.rb', line 30

def create
  @rating = Rating.new(rating_params)
  authorize @rating
  respond_to do |format|
    if @rating.save
      format.html { redirect_to @rating, notice: 'Rating was successfully created.' }
      format.json { render :show, status: :created, location: @rating }
    else
      format.html { render :new }
      format.json { render json: @rating.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /ratings/1 DELETE /ratings/1.json


60
61
62
63
64
65
66
# File 'app/controllers/ratings_controller.rb', line 60

def destroy
  @rating.destroy
  respond_to do |format|
    format.html { redirect_to ratings_url, notice: 'Rating was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /ratings/1/edit


26
# File 'app/controllers/ratings_controller.rb', line 26

def edit() end

#indexObject

GET /ratings GET /ratings.json


9
10
11
12
13
# File 'app/controllers/ratings_controller.rb', line 9

def index
  @ratings = Rating.all
  return unless params[:playbook_id]
  @ratings = @ratings.where(playbook_id: params[:playbook_id])
end

#newObject

GET /ratings/new


20
21
22
23
# File 'app/controllers/ratings_controller.rb', line 20

def new
  @rating = Rating.new
  authorize @rating
end

#showObject

GET /ratings/1 GET /ratings/1.json


17
# File 'app/controllers/ratings_controller.rb', line 17

def show() end

#updateObject

PATCH/PUT /ratings/1 PATCH/PUT /ratings/1.json


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

def update
  respond_to do |format|
    if @rating.update(rating_params)
      format.html { redirect_to @rating, notice: 'Rating was successfully updated.' }
      format.json { render :show, status: :ok, location: @rating }
    else
      format.html { render :edit }
      format.json { render json: @rating.errors, status: :unprocessable_entity }
    end
  end
end