Sha256: 946c279f16512505fb056881f5cc2e56d711cc5b16e10ee1d3215f776b9e8dc7
Contents?: true
Size: 1.87 KB
Versions: 24
Compression:
Stored size: 1.87 KB
Contents
class RolesController < ApplicationController force_ssl if: :ssl_configured? before_action :set_role, only: [:show, :edit, :update, :destroy] # GET /roles # GET /roles.json def index @roles = Role.all end # GET /roles/1 # GET /roles/1.json def show end # GET /roles/new def new @role = Role.new end # GET /roles/1/edit def edit end # POST /roles # POST /roles.json def create @role = Role.new(role_params) respond_to do |format| if @role.save format.html { redirect_to @role, notice: 'Role was successfully created.' } format.json { render :show, status: :created, location: @role } else format.html { render :new } format.json { render json: @role.errors, status: :unprocessable_entity } end end end # PATCH/PUT /roles/1 # PATCH/PUT /roles/1.json def update respond_to do |format| if @role.update(role_params) format.html { redirect_to @role, notice: 'Role was successfully updated.' } format.json { render :show, status: :ok, location: @role } else format.html { render :edit } format.json { render json: @role.errors, status: :unprocessable_entity } end end end # DELETE /roles/1 # DELETE /roles/1.json def destroy @role.destroy respond_to do |format| format.html { redirect_to roles_url, notice: 'Role was successfully destroyed.' } format.json { head :no_content } end end private # Always enforce SSL for this controller def ssl_configured? Rails.env.production? end # Use callbacks to share common setup or constraints between actions. def set_role @role = Role.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def role_params params.require(:role).permit(:name) end end
Version data entries
24 entries across 24 versions & 1 rubygems