Witam, po zmianach w pliku show.html.erb wyskakuje mi taki błąd, próbowałem już różnych opcji i nic. Dodałem tylko te wartości w znacznikach <%= ... %>
localhost:3000/ads/3
ActiveRecord::RecordNotFound in AdsController#show
Couldn't find Ad with 'id'=3
Extracted source (around line #3):
1
2
3
4
5
6
class AdsController < ApplicationController
def show
@ad = Ad.find(params[:id])
end
end
Rails.root: /home/userek/Rails/mebay/mebay
Application Trace | Framework Trace | Full Trace
app/controllers/ads_controller.rb:3:in `show'
Request
Parameters:
{"id"=>"3"}
shwo.html.erb
<html>
<head>
<title><%= @ad.name %></title>
</head>
<body>
<p>
<b>Name:</b><%= @ad.name %>
</p>
<p>
<b>Description:</b><%= @ad.description %>
</p>
<p>
<b>Price:</b><%= @ad.price %>
</p>
<p>
<b>Seller Id:</b><%= @ad.seller_id %>
</p>
<p>
<b>Email:</b><%= @ad.email %>
</p>
<p>
<img src="<%= @ad.img_url %>"/>
</p>
</body>
</html>
routes.rb
Rails.application.routes.draw do
resources :ads, only: :show
end
ads.controller.rb
class AdsController < ApplicationController
def show
@ad = Ad.find(params[:id])
end
end