Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ActiveRecord::ActsAs路由问题_Ruby On Rails_Ruby On Rails 4_Nested Routes_Multi Table Inheritance - Fatal编程技术网

Ruby on rails ActiveRecord::ActsAs路由问题

Ruby on rails ActiveRecord::ActsAs路由问题,ruby-on-rails,ruby-on-rails-4,nested-routes,multi-table-inheritance,Ruby On Rails,Ruby On Rails 4,Nested Routes,Multi Table Inheritance,将旧的Rails 3应用程序升级到Rails 4,多表继承gem已因不推荐而更改。现在,使用 嵌套路由不工作,产生以下错误: undefined method `vehicle_path' for #<#<Class:0x007f0e2778da70>:0x007f0e26725778> 父类: class Vehicle < ActiveRecord::Base actable end class Vehicles::Car < ActiveReco

将旧的Rails 3应用程序升级到Rails 4,多表继承gem已因不推荐而更改。现在,使用

嵌套路由不工作,产生以下错误:

undefined method `vehicle_path' for #<#<Class:0x007f0e2778da70>:0x007f0e26725778>
父类:

class Vehicle < ActiveRecord::Base
  actable
end
class Vehicles::Car < ActiveRecord::Base
  acts_as :vehicle
end
namespace :vehicles do
  resources :cars, except: [:index]
end
任何帮助都将不胜感激

更新:Rake路由

vehicles          GET    /:locale/vehicles(.:format)                  vehicles#index {:locale=>/en|es/}

vehicles_cars     POST   /:locale/vehicles/cars(.:format)             vehicles/cars#create {:locale=>/en|es/}

new_vehicles_car  GET    /:locale/vehicles/cars/new(.:format)         vehicles/cars#new {:locale=>/en|es/}

edit_vehicles_car GET    /:locale/vehicles/cars/:id/edit(.:format)    vehicles/cars#edit {:locale=>/en|es/}

vehicles_car      GET    /:locale/vehicles/cars/:id(.:format)         vehicles/cars#show {:locale=>/en|es/}

                  PATCH  /:locale/vehicles/cars/:id(.:format)         vehicles/cars#update {:locale=>/en|es/}

                  PUT    /:locale/vehicles/cars/:id(.:format)         vehicles/cars#update {:locale=>/en|es/}

                  DELETE /:locale/vehicles/cars/:id(.:format) 

什么输出为您提供了
rake路由
?@AlejandroMontilla,已更新。谢谢。您可以尝试使用类似于
%td=link\u to vehicle.code,vehicles\u path(vehicle,@car)
的方法,其中
@car
是要显示的汽车的外观。“vehicle”是对象的实例。此车辆可能是一辆汽车或其他东西。您是否尝试过使用
%td=link\u to vehicle.code,vehicles\u car\u path(vehicle)
?输出为您提供了什么
rake routes
?@AlejandroMontilla,已更新。谢谢。您可以尝试使用类似于
%td=link\u to vehicle.code,vehicles\u path(vehicle,@car)
的方法,其中
@car
是要显示的汽车的外观。“vehicle”是对象的实例。此车辆可能是一辆汽车或其他东西。您是否尝试使用
%td=link\u to vehicle.code,vehicles\u car\u路径(车辆)
vehicles          GET    /:locale/vehicles(.:format)                  vehicles#index {:locale=>/en|es/}

vehicles_cars     POST   /:locale/vehicles/cars(.:format)             vehicles/cars#create {:locale=>/en|es/}

new_vehicles_car  GET    /:locale/vehicles/cars/new(.:format)         vehicles/cars#new {:locale=>/en|es/}

edit_vehicles_car GET    /:locale/vehicles/cars/:id/edit(.:format)    vehicles/cars#edit {:locale=>/en|es/}

vehicles_car      GET    /:locale/vehicles/cars/:id(.:format)         vehicles/cars#show {:locale=>/en|es/}

                  PATCH  /:locale/vehicles/cars/:id(.:format)         vehicles/cars#update {:locale=>/en|es/}

                  PUT    /:locale/vehicles/cars/:id(.:format)         vehicles/cars#update {:locale=>/en|es/}

                  DELETE /:locale/vehicles/cars/:id(.:format)