我正尝试在Ruby on Rails应用程序中为每个餐厅创建一个信息页。我在Restaurant controller
中创建了一个动作info
,并在routes.rb
中添加了一行。但它给出了一个错误用Ruby on Rails为每个餐厅创建信息页
“的ActiveRecord :: RecordNotFound在RestaurantsController#信息” 无法找到 与餐厅 '身份证'= ..
什么是错我的代码?
这是我的餐厅控制器:
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
这是我的routes.rb:
Rails.application.routes.draw do
resources :restaurants do
get '/info', to: 'restaurants#info'
end
end
这一个链接到餐馆信息页面:
<%= link_to 'Info', restaurant_info_path(@restaurant) %>
你在哪个页面有这条线<%= link_to'Info',restaurant_info_path(@restaurant)%>'? – Pavan
谢谢您的回复!在餐厅展示页面。 – sevmilber