ActiveRecord :: ActsAs路由问题

时间:2017-04-24 11:44:31

标签: ruby-on-rails ruby-on-rails-4 nested-routes multi-table-inheritance

将旧的Rails 3应用程序升级到Rails 4,由于弃用,已更改多个表继承gem。现在,使用ActsAs

嵌套路由不起作用产生以下错误:

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

被召唤时:

  - @vehicles.each do |vehicle|
    %tr
      %td= link_to vehicle.code, vehicle

家长班:

class Vehicle < ActiveRecord::Base
  actable
end

儿童班:

class Vehicles::Car < ActiveRecord::Base
  acts_as :vehicle
end

routes.rb中:

namespace :vehicles do
  resources :cars, except: [:index]
end

任何帮助都将不胜感激。

更新:佣金路线

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) 

0 个答案:

没有答案