Hartl 教程中的下一个新手问题。现在在第 7 章。当我运行应用程序时,我在浏览器中得到了类似的东西:
ActiveRecord::RecordNotFound in UsersController#show
Couldn't find User with id=1
Rails.root: C:/rails_project/my_app
Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:4:in `show'
Request
Parameters:
{"id"=>"1"}
Show session dump
Show env dump
Response
Headers:
None
我的 user_controller.rb 看起来像这样:
class UsersController < ApplicationController
def show
@user = User.find(params[:id])
describe "profile page" do
#Code to make a user variable
before { visit user_path(user) }
it { should have_selector('h1', :text => user.name) }
it { should have_selector('title', :text => user.name) }
end
end
def new
end
end
感谢您的帮助和兴趣!