0
我想有一个名为locations的表的第二个显示文件。 该文件的意见/位置/ show2.html.erbRails添加第二个显示视图
我已经添加了第二个指数叫index2.html.erb和我通过
locations_index2_path
- 访问它,我有一个路线名为get “位置/索引2”
但是,如果我尝试类似的东西,这是行不通的:
location_show2_path(location)
我还添加了这位置控制器:
def show2
@location = Location.find(params[:id])
end
谢谢!
更新 - 我得到 参数 “无ID找不到位置”:
{"format"=>"14"}
网址:
http://localhost:5000/locations/show2.14
路线:
get "locations/show2"
位置控制器:
def show2
@location = Location.find(params[:id])
respond_to do |format|
format.html # show2.html.erb
format.json { render json: @location }
end
end
链接在索引视图:
<%= link_to 'Show', locations_show2_path(location), :class => 'btn btn-mini btn-success' %>
您是否将路线添加到show2? – MurifoX
仍然收到错误 - 我更新了我的问题。 – Reddirt