我正在使用RailsTutorial.org学习rails并在section 7.3.4中遇到问题
它希望我运行get signup_path
但我在尝试时遇到此错误:
NameError: undefined local variable or method `signup_path' for main:Object
from (irb):2
from /Users/reubenpressman/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.8/lib/rails/commands/console.rb:90:in `start'
from /Users/reubenpressman/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.8/lib/rails/commands/console.rb:9:in `start'
from /Users/reubenpressman/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.8/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
这是我的routes.rb文件的样子
get "users/new"
root 'static_pages#home'
match '/signup', to:'users#new', via:'get'
match '/help', to:'static_pages#help', via:'get'
match '/about', to:'static_pages#about', via:'get'
match '/contact', to:'static_pages#contact', via:'get'
resources :users
任何帮助都会很棒,谢谢!
答案 0 :(得分:2)
你刚刚用irb运行吗?如果你这样需要在你的RSpec测试中,而不仅仅是从控制台运行。 &#34;得到&#34;这里的方法是RSpec的一部分:https://www.relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec