Sha256: 787b5694c4e950c95bd0ac4d768f4e9e0d6a41e862ce1ff1471416e046164c22
Contents?: true
Size: 993 Bytes
Versions: 10
Compression:
Stored size: 993 Bytes
Contents
class RatingsController < ApplicationController def index authorize skip_scoping: true @ratings = apply_authz_scopes(on: Rating) .includes(:user, :city, :report) .order('cities.name ASC, reports.id ASC') end def new @report = Report.find params[:report_id] authorize using: @report @rating = Rating.new user: current_user, report: @report end def create @rating = Rating.new(rating_params) @rating.user = current_user authorize using: @rating if @rating.save redirect_to @rating.report, notice: 'Rating was successfully created.' else render :new end end def destroy @rating = Rating.find params[:id] authorize using: @rating @rating.destroy redirect_to ratings_url, notice: 'Rating was successfully destroyed.' end private # Only allow a trusted parameter "white list" through. def rating_params params.require(:rating).permit(:score, :report_id) end end
Version data entries
10 entries across 10 versions & 1 rubygems