Reputation: 525
I am trying to integrate stripe payments into my pin scaffolding (RoR) and currently get the following error.
Here is the following error message below and it highlights "@pin = Pin.find(params[:id])":
ActiveRecord::RecordNotFound in PinsController#show
private
def set_pin
@pin = Pin.find(params[:id])
end
def correct_user
Here are my routes.rb
Rails.application.routes.draw do
resources :pins
devise_for :users
root "pins#index"
get "about" => "pages#about" #creates about_path
get "contact" => "pages#contact" #creates contact_path
get "auction" => "pages#auction" #creates auction_path
get "terms" => "pages#terms" #creates terms_path
post 'send_mail', to: 'contact#send_mail'
get 'contact', to: 'contact#show'
scope 'pins', controller: :pins do
scope '/:id' do
post 'bid', to: :bid
end
end
scope 'admin', controller: :admin do
scope 'pins' do
get '/:pin_id', to: :pin
end
end
end
How do I resolve this issue and get started on the right path? Thank you!
Upvotes: 0
Views: 49
Reputation: 2762
What route are you hitting? If it's the admin route, you've set the route to pass the parameter as pin_id
not id
. So change your route that is currently
get '/:pin_id', to: :pin
to
get '/:id', to: :pin
Or change your controller to look for params[:pin_id]
.
Upvotes: 1