Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ProxiesController < ApplicationController
- before_action :set_proxy, only: [:show, :edit, :update, :destroy]
- before_action :authenticate_user!
- def index
- @proxies = policy_scope(Proxy)
- #@proxies = current_user.proxies
- end
- def show
- authorize @proxy
- end
- def new
- @proxy = Proxy.new(user: current_user)
- authorize @proxy
- end
- def edit
- authorize @proxy
- end
- def create
- @proxy = current_user.proxies.build(proxy_params)
- authorize @proxy
- respond_to do |format|
- if @proxy.save
- format.html { redirect_to @proxy, notice: 'Proxy was successfully created.' }
- format.json { render :show, status: :created, location: @proxy }
- else
- format.html { render :new }
- format.json { render json: @proxy.errors, status: :unprocessable_entity }
- end
- end
- end
- def update
- authorize @proxy
- respond_to do |format|
- if @proxy.update(proxy_params)
- format.html { redirect_to @proxy, notice: 'Proxy was successfully updated.' }
- format.json { render :show, status: :ok, location: @proxy }
- else
- format.html { render :edit }
- format.json { render json: @proxy.errors, status: :unprocessable_entity }
- end
- end
- end
- def destroy
- authorize @proxy
- @proxy.destroy
- respond_to do |format|
- format.html { redirect_to proxies_url, notice: 'Proxy was successfully destroyed.' }
- format.json { head :no_content }
- end
- end
- private
- # Use callbacks to share common setup or constraints between actions.
- def set_proxy
- @proxy = Proxy.find(params[:id])
- end
- # Never trust parameters from the scary internet, only allow the white list through.
- def proxy_params
- params.require(:proxy).permit(:user_id, :ip, :port, :country, :city, :username, :password)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement