【发布时间】:2017-05-08 06:02:53
【问题描述】:
我想要显示的页面不是索引、显示、编辑等。我想要的页面是 adoption.html.erb,但由于某种原因它正在获取显示页面 ID。在我的views/shared/_header.html.erb 文件中,我有<li><%= link_to "More About Dog Adoption", adoption_info_path, class: "dog-adopt-info" %></li>。应该去这里:adoption.html.erb,但错误的是:Couldn't find Dog with 'id'=adoption。我真的很困惑,不知道为什么它会从节目中获取 id。想法?附言如果您需要更多信息,请告诉我。
class DogsController < ApplicationController
def index
@dogs = Dog.all
end
def show
@dog = Dog.find(params[:id])
end
def adoption
end
end
routes.rb
resources :dogs, only: [:index, :show]
get "dogs/adoption", as: "adoption_info"
app/views/shared/_header.html.erb
<a class="page-scroll" href="#about">About Dog Adoption</a>
<ul class="about-dog-adoption">
<li><%= link_to "More About Dog Adoption", adoption_info_path, class: "dog-adopt-info" %></li>
</ul>
我的 rspec 测试通过了,这似乎是误报:
context "#dogs_adoption" do
it "renders more info about dog adoptions" do
get :adoption
expect(response).to have_http_status(200)
end
end
【问题讨论】:
标签: ruby-on-rails routes capybara erb rspec-rails