I am trying to create an info page for each restaurant in a Ruby on rails app. I created an action info
in Restaurant controller
and added a line in routes.rb
. but it gives an error
"ActiveRecord::RecordNotFound in RestaurantsController#info" Couldn't find Restaurant with 'id'=..
What is wrong with my code?
This is my Restaurant controller:
class RestaurantsController < ApplicationController
before_action :set_restaurant, only: [:show, :edit, :update, :destroy, :info]
def info
end
private
def set_restaurant
@restaurant = Restaurant.find(params[:id])
end
end
This is my routes.rb:
Rails.application.routes.draw do
resources :restaurants do
get '/info', to: 'restaurants#info'
end
end
And this a link to restaurant info page:
<%= link_to 'Info', restaurant_info_path(@restaurant) %>