title: ActiveRecord::RecordNotFound in PermitsController#show, Couldn't find Permit with 'id'=
body: <p>Hi guys I keep get this error when i try to access to SHOW action(Manage permit button on user/show.html.erb) which should display all the permits of a specific user, i search through all my code and couldn't find the bug. Can you guys help me to check which part i did wrong? Btw I'm implementing a website using Ruby on rails</p>
  
  <p>This is my permits_controller.rb</p>
  
  <pre><code>class PermitsController &lt; ApplicationController
    before_action :set_permit, only: [:show, :destroy]
    def index
      @permits = Permit.where(:user_id =&gt; current_user.id)
    end
  
    def new
      @permits = Permit.new
    end
  
    def create
      @permits = current_user.permits.build(permit_params)
      if @permits.save
        redirect_to invoice_path
      else
        render 'new'
      end
    end
  
  
    def destroy
      Permit.destroy_all(user_id: current_user)
      respond_to do |format|
        format.html { redirect_to root_path, notice: 'Permit was successfully canceled.' }
        format.json { head :no_content }
      end
    end
  
    def confirm
      @fields = %i[vehicle_type, carplate, studentid, name, department, permitstart, permitend]
      @permit = current_user.permits.build(permit_params)
      render :new and return unless @permit.valid?
    end
  
  
  
    def show
      @permits = Permit.where(:user_id =&gt; current_user.id)
  
  
    end
  
    def update
      @permits = Permit.where(user_id: current_user).take
      respond_to do |format|
        if @permits.update(permit_params)
          format.html { redirect_to root_path}
          flash[:success] = "Permit successfully updated"
          format.json { render :show, status: :ok, location: @user }
        else
          format.html { render :edit }
          format.json { render json: @user.errors, status: :unprocessable_entity }
        end
      end
    end
  
    def edit
      @permits = Permit.find(params[:id])
      #@permits = Permit.find_or_initialize_by(user_id: params[:id])
    end
  
    private
    # Use callbacks to share common setup or constraints between actions.
    def set_permit
      @permits = Permit.find(params[:id])
    end
  
    # Never trust parameters from the scary internet, only allow the white list through.
    def permit_params
      params.require(:permit).permit(:vehicle_type, :name, :studentid, :department, :carplate, :duration, :permitstart, :permitend)
    end
  end
  </code></pre>
  
  <p>This is my permits/show.html.erb</p>
  
  <pre><code>&lt;%= @permits.name %&gt;
  </code></pre>
  
  <p>This is my route.db</p>
  
  <pre><code>Rails.application.routes.draw do
    resources :users
    resources :permits do
      collection do
        post :confirm
      end
    end
    resources :visitor_permits
    root 'static_pages#home'
    get 'invoice' =&gt; 'permits#invoice'
    get 'payment' =&gt;'transaction#new'
    get 'show_visitor_permit' =&gt;'visitor_permits#show'
    get 'show_permit' =&gt;'permits#show'
    get 'visitorpermit' =&gt; 'visitor_permits#new'
    post 'createpermit' =&gt; 'permits#create'
    get 'homepage/index'
    post 'permits' =&gt; 'permits#create'
    get 'permitapplication' =&gt; 'permits#new'
    get 'adminlogin' =&gt; 'admin_controller#index'
    get 'patrollogin' =&gt; 'patrol_officer_controller#index'
    get 'createcitation' =&gt; 'citations#new'
    get 'contact'=&gt; 'static_pages#contact'
    get 'about' =&gt; 'static_pages#about'
    get 'signup' =&gt; 'users#new'
    get 'help' =&gt; 'static_pages#help'
    post 'users' =&gt; 'users#create'
    get 'login' =&gt; 'sessions#new' #Page for a new session
    post 'login' =&gt; 'sessions#create' #Create a new session
    delete 'logout'=&gt;'sessions#destroy' #Delete a session
  
  
    # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  end
  </code></pre>
  
  <p>users/show.html.erb</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;div id="sidebar"&gt;
  &lt;ul id="mySidenav" class="sidenav"&gt;
    &lt;li&gt;&lt;%= link_to "New Parking Permit", permitapplication_path %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "Manage Permit", show_permit_path(@permit) %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "New Visitor Parking Permit", visitorpermit_path %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "Manage Visitor Permit", "#" %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "Check Fines", "#" %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "New Health and Safety Report", "#" %&gt;&lt;/li&gt;
    &lt;li&gt;&lt;%= link_to "Manage Health and Safety Report", "#" %&gt;&lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>