class PublickeysController < ApplicationController before_action :set_publickey, only: [:show, :edit, :update, :destroy] skip_before_action :verify_authenticity_token, only: [:create] # GET /publickeys # GET /publickeys.json def index @publickeys = Publickey.all end # GET /publickeys/1 # GET /publickeys/1.json def show end # GET /publickeys/new def new @publickey = Publickey.new end # GET /publickeys/1/edit def edit end # POST /publickeys # POST /publickeys.json def create @publickey = Publickey.new(publickey_params) @publickey.user = User.find_by_token(params[:token]) respond_to do |format| if @publickey.save format.html { redirect_to @publickey, notice: 'Publickey was successfully created.' } format.json { render :show, status: :created, location: @publickey } else format.html { render :new } format.json { render json: @publickey.errors, status: :unprocessable_entity } end end end # PATCH/PUT /publickeys/1 # PATCH/PUT /publickeys/1.json def update respond_to do |format| if @publickey.update(publickey_params) format.html { redirect_to @publickey, notice: 'Publickey was successfully updated.' } format.json { render :show, status: :ok, location: @publickey } else format.html { render :edit } format.json { render json: @publickey.errors, status: :unprocessable_entity } end end end # DELETE /publickeys/1 # DELETE /publickeys/1.json def destroy @publickey.destroy respond_to do |format| format.html { redirect_to publickeys_url, notice: 'Publickey was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_publickey @publickey = Publickey.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def publickey_params params.require(:publickey).permit(:name, :data, :user_id) end end