Вот мой тест:NoMethodError: неопределенный метод `zombie_url»
require 'test_helper'
class CreatingZombiesTest < ActionDispatch::IntegrationTest
setup { host! 'api.example.com' }
test 'creates a new zombie' do
post '/zombies',
{ zombie:
{ name: 'brain_eater', weapon: 'teeth'}
}.to_json,
{ 'Accept' => Mime::JSON, 'Content-Type' => Mime::JSON.to_s }
assert_equal 201, response.status
end
end
И контроллер:
def create
@zombie = Zombie.new(zombie_params)
if @zombie.save
render json: @zombie, status: 201, location: @zombie
end
end
Я получаю эту ошибку, поиск не был полезен.
CreatingZombiesTest#test_creates_a_new_zombie:
NoMethodError: undefined method `zombie_url' for #<Api::ZombiesController:0x007f8ef9f6cd60>
app/controllers/api/zombies_controller.rb:22:in `create
Маршруты:
Prefix Verb URI Pattern Controller#Action
api_zombies GET /zombies(.:format) api/zombies#index {:subdomain=>"api"}
POST /zombies(.:format) api/zombies#create {:subdomain=>"api"}
new_api_zombie GET /zombies/new(.:format) api/zombies#new {:subdomain=>"api"}
edit_api_zombie GET /zombies/:id/edit(.:format) api/zombies#edit {:subdomain=>"api"}
api_zombie GET /zombies/:id(.:format) api/zombies#show {:subdomain=>"api"}
PATCH /zombies/:id(.:format) api/zombies#update {:subdomain=>"api"}
PUT /zombies/:id(.:format) api/zombies#update {:subdomain=>"api"}
DELETE /zombies/:id(.:format) api/zombies#destroy {:subdomain=>"api"}
Возможно, это может быть дополнительным комментарием относительно того, почему это устраняет проблему , – Iguananaut
Как нас найти? , –